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 DrawSynchronizeScaleData()
     {
         if (this.m_SynchronizeScaleProperty == null || this.m_SynchronizeScaleProperty.boolValue == false)
         {
             return;
         }

         SerializedProperty interpolateScaleProperty = serializedObject.FindProperty("m_ScaleModel.InterpolateOption");
         PhotonTransformViewScaleModel.InterpolateOptions interpolateOption = (PhotonTransformViewScaleModel.InterpolateOptions) interpolateScaleProperty.enumValueIndex;

         float containerHeight = EDITOR_LINE_HEIGHT;

         switch (interpolateOption)
         {
             case PhotonTransformViewScaleModel.InterpolateOptions.MoveTowards:
             case PhotonTransformViewScaleModel.InterpolateOptions.Lerp:
                 containerHeight += EDITOR_LINE_HEIGHT;
                 break;
         }

         if (this.m_InterpolateScaleHelpOpen == true)
         {
             containerHeight += GetInterpolateHelpBoxHeight();
         }

         Rect rect = PhotonGUI.ContainerBody(containerHeight);
         Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);

         DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateScaleHelpOpen, interpolateScaleProperty, INTERPOLATE_TOOLTIP);
         DrawHelpBox(ref propertyRect, this.m_InterpolateScaleHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);

         switch (interpolateOption)
         {
             case PhotonTransformViewScaleModel.InterpolateOptions.MoveTowards:
                 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_ScaleModel.InterpolateMoveTowardsSpeed"),
                     new GUIContent("MoveTowards Speed"));
                 break;
             case PhotonTransformViewScaleModel.InterpolateOptions.Lerp:
                 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_ScaleModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
                 break;
         }
     }