예제 #1
0
 private void SetRTPCDefaults()
 {
     for (int i = 0; i < this.rtpcs.Length; i++)
     {
         RTPC currentRTPC = this.rtpcs[i];
         currentRTPC.value = currentRTPC.defaultValue;
     }
 }
예제 #2
0
        private void DrawRTPCHeader()
        {
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            this.showRTPCs = EditorGUILayout.Foldout(this.showRTPCs, "RTPCs");

            if (this.showRTPCs)
            {
                using (new EditorGUI.DisabledScope((this.myTarget.editorRTPCs == null) || (this.myTarget.editorRTPCs.Length == 0)))
                {
                    if (GUILayout.Button("Remove RTPC"))
                    {
                        RTPC rtpcToRemove = this.myTarget.editorRTPCs[this.selectedRTPCIndex];

                        this.serializedObject.FindProperty("rtpcs").GetArrayElementAtIndex(this.selectedRTPCIndex).DeleteCommand();
                        this.serializedObject.FindProperty("rtpcs").DeleteArrayElementAtIndex(this.selectedRTPCIndex);
                        this.serializedObject.ApplyModifiedProperties();

                        DestroyImmediate(rtpcToRemove);

                        UpdateRTPCNames();

                        // Remove references to this RTPC from all existing events.
                        for (int i = 0; i < this.myTarget.EditorEvents.Length; i++)
                        {
                            this.myTarget.EditorEvents[i].rtpcs = RemoveElement(this.myTarget.EditorEvents[i].rtpcs, rtpcToRemove);
                        }

                        this.serializedObject.Update();

                        if (this.selectedRTPCIndex >= this.myTarget.editorRTPCs.Length)
                        {
                            this.selectedRTPCIndex = this.myTarget.editorRTPCs.Length - 1;
                        }
                    }
                }

                if (GUILayout.Button("Add RTPC"))
                {
                    RTPC rtpc = this.rtpcGameObject.AddComponent <RTPC>();

                    int length = this.myTarget.editorRTPCs.Length;
                    this.serializedObject.FindProperty("rtpcs").InsertArrayElementAtIndex(length);
                    this.serializedObject.FindProperty("rtpcs").GetArrayElementAtIndex(length).objectReferenceValue = rtpc;
                    this.serializedObject.ApplyModifiedProperties();
                    UpdateRTPCNames();

                    this.selectedRTPCIndex = length;
                }
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
        }
예제 #3
0
 public void SetRTPC(string rtpcName, float newValue)
 {
     for (int i = 0; i < this.rtpcs.Length; i++)
     {
         RTPC currentRTPC = this.rtpcs[i];
         if (currentRTPC.RTPCName == rtpcName)
         {
             currentRTPC.value = newValue;
         }
     }
 }
예제 #4
0
        private void DrawRTPCInspector()
        {
            if (this.showRTPCs && this.myTarget.editorRTPCs != null && this.myTarget.editorRTPCs.Length > 0)
            {
                EditorGUI.indentLevel++;

                this.selectedRTPCIndex = EditorGUILayout.Popup(this.selectedRTPCIndex, this.rtpcNames);

                if (this.selectedRTPCIndex >= 0 && this.myTarget.editorRTPCs.Length > 0)
                {
                    RTPC             currentRTPC          = this.myTarget.editorRTPCs[this.selectedRTPCIndex];
                    SerializedObject rtpcSerializedObject = new SerializedObject(currentRTPC);
                    DisplayAllProperties(rtpcSerializedObject);

                    // Update the name for the current RTPC so that it updates as the user modifies it.
                    // This allows us not to update every name every frame.
                    this.rtpcNames[this.selectedRTPCIndex] = currentRTPC.RTPCName;
                }

                EditorGUI.indentLevel--;
            }
        }
예제 #5
0
        private void UpdateRTPCNames()
        {
            HashSet <string> previousRTPCNames = new HashSet <string>();

            this.rtpcNames = new string[this.myTarget.editorRTPCs.Length];

            for (int i = 0; i < this.myTarget.editorRTPCs.Length; i++)
            {
                RTPC rtpc = this.myTarget.editorRTPCs[i];

                if (string.IsNullOrEmpty(rtpc.RTPCName))
                {
                    rtpc.RTPCName = "_NewRTPC";
                }

                while (previousRTPCNames.Contains(rtpc.RTPCName))
                {
                    rtpc.RTPCName = "_" + rtpc.RTPCName;
                }

                this.rtpcNames[i] = rtpc.RTPCName;
                previousRTPCNames.Add(this.rtpcNames[i]);
            }
        }