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:

     public override void OnInspectorGUI()
     {
         //base.OnInspectorGUI();

         if (this.m_Animator == null)
         {
             GUILayout.BeginVertical(GUI.skin.box);
             GUILayout.Label("GameObject doesn't have an Animator component to synchronize");
             GUILayout.EndVertical();
             return;
         }

         DrawWeightInspector();

         if (this.m_Animator.layerCount == 0)
         {
             GUILayout.BeginVertical(GUI.skin.box);
             GUILayout.Label("Animator doesn't have any layers setup to synchronize");
             GUILayout.EndVertical();
         }

         DrawParameterInspector();

         if (GetParameterCount() == 0)
         {
             GUILayout.BeginVertical(GUI.skin.box);
             GUILayout.Label("Animator doesn't have any parameters setup to synchronize");
             GUILayout.EndVertical();
         }

         serializedObject.ApplyModifiedProperties();

         //GUILayout.Label( "m_SynchronizeLayers " + serializedObject.FindProperty( "m_SynchronizeLayers" ).arraySize );
         //GUILayout.Label( "m_SynchronizeParameters " + serializedObject.FindProperty( "m_SynchronizeParameters" ).arraySize );
     }