Copying and Pasting cs Code
In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.
For example, you can follow the pattern in this listing: private void DrawSynchronizePositionData()
{
if (this.m_SynchronizePositionProperty == null || this.m_SynchronizePositionProperty.boolValue == false)
{
return;
}
SerializedProperty interpolatePositionProperty = serializedObject.FindProperty("m_PositionModel.InterpolateOption");
PhotonTransformViewPositionModel.InterpolateOptions interpolateOption = (PhotonTransformViewPositionModel.InterpolateOptions)interpolatePositionProperty.enumValueIndex;
SerializedProperty extrapolatePositionProperty = serializedObject.FindProperty("m_PositionModel.ExtrapolateOption");
PhotonTransformViewPositionModel.ExtrapolateOptions extrapolateOption = (PhotonTransformViewPositionModel.ExtrapolateOptions)extrapolatePositionProperty.enumValueIndex;
float containerHeight = 155;
switch (interpolateOption)
{
case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
containerHeight += EDITOR_LINE_HEIGHT;
break;
/*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
containerHeight += EDITOR_LINE_HEIGHT*3;
break;*/
}
if (extrapolateOption != PhotonTransformViewPositionModel.ExtrapolateOptions.Disabled)
{
containerHeight += EDITOR_LINE_HEIGHT;
}
switch (extrapolateOption)
{
case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
containerHeight += EDITOR_LINE_HEIGHT;
break;
}
if (this.m_InterpolateHelpOpen == true)
{
containerHeight += GetInterpolateHelpBoxHeight();
}
if (this.m_ExtrapolateHelpOpen == true)
{
containerHeight += GetExtrapolateHelpBoxHeight();
}
// removed Gizmo Options. -3 lines, -1 splitter
containerHeight -= EDITOR_LINE_HEIGHT * 2;
Rect rect = PhotonGUI.ContainerBody(containerHeight);
Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
DrawTeleport(ref propertyRect);
DrawSplitter(ref propertyRect);
DrawSynchronizePositionDataInterpolation(ref propertyRect, interpolatePositionProperty, interpolateOption);
DrawSplitter(ref propertyRect);
DrawSynchronizePositionDataExtrapolation(ref propertyRect, extrapolatePositionProperty, extrapolateOption);
DrawSplitter(ref propertyRect);
DrawSynchronizePositionDataGizmos(ref propertyRect);
}
{
if (this.m_SynchronizePositionProperty == null || this.m_SynchronizePositionProperty.boolValue == false)
{
return;
}
SerializedProperty interpolatePositionProperty = serializedObject.FindProperty("m_PositionModel.InterpolateOption");
PhotonTransformViewPositionModel.InterpolateOptions interpolateOption = (PhotonTransformViewPositionModel.InterpolateOptions)interpolatePositionProperty.enumValueIndex;
SerializedProperty extrapolatePositionProperty = serializedObject.FindProperty("m_PositionModel.ExtrapolateOption");
PhotonTransformViewPositionModel.ExtrapolateOptions extrapolateOption = (PhotonTransformViewPositionModel.ExtrapolateOptions)extrapolatePositionProperty.enumValueIndex;
float containerHeight = 155;
switch (interpolateOption)
{
case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
containerHeight += EDITOR_LINE_HEIGHT;
break;
/*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
containerHeight += EDITOR_LINE_HEIGHT*3;
break;*/
}
if (extrapolateOption != PhotonTransformViewPositionModel.ExtrapolateOptions.Disabled)
{
containerHeight += EDITOR_LINE_HEIGHT;
}
switch (extrapolateOption)
{
case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
containerHeight += EDITOR_LINE_HEIGHT;
break;
}
if (this.m_InterpolateHelpOpen == true)
{
containerHeight += GetInterpolateHelpBoxHeight();
}
if (this.m_ExtrapolateHelpOpen == true)
{
containerHeight += GetExtrapolateHelpBoxHeight();
}
// removed Gizmo Options. -3 lines, -1 splitter
containerHeight -= EDITOR_LINE_HEIGHT * 2;
Rect rect = PhotonGUI.ContainerBody(containerHeight);
Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
DrawTeleport(ref propertyRect);
DrawSplitter(ref propertyRect);
DrawSynchronizePositionDataInterpolation(ref propertyRect, interpolatePositionProperty, interpolateOption);
DrawSplitter(ref propertyRect);
DrawSynchronizePositionDataExtrapolation(ref propertyRect, extrapolatePositionProperty, extrapolateOption);
DrawSplitter(ref propertyRect);
DrawSynchronizePositionDataGizmos(ref propertyRect);
}