public override void OnInspectorGUI()
        {
            GUI.enabled = !Application.isPlaying;

            serializedObject.Update();

            SerializedProperty recordDestructionProperty   = serializedObject.FindProperty("recordDestruction");
            SerializedProperty recordInstantiationProperty = serializedObject.FindProperty("recordInstantiation");

            EditorGUILayout.LabelField("Record Options", EditorStyles.miniBoldLabel);
            EditorGUILayout.BeginHorizontal();
            SetBool(recordDestructionProperty.prefabOverride);
            recordDestructionProperty.boolValue = EditorGUILayout.Toggle("Destruction", recordDestructionProperty.boolValue);
            SetBool(recordInstantiationProperty.prefabOverride);
            recordInstantiationProperty.boolValue = EditorGUILayout.Toggle("Instantiation", recordInstantiationProperty.boolValue);
            EditorGUILayout.EndHorizontal();
            SetBool(false);
            EditorGUILayout.LabelField("Recorded Components", EditorStyles.miniBoldLabel);

            SerializedProperty recordedComponentsProperty = serializedObject.FindProperty("recordedComponents");

            EditorGUILayout.BeginHorizontal();
            SetBool(recordedComponentsProperty.prefabOverride);
            int i         = 0;
            int numPerRow = 2;

            foreach (Component component in editTarget.GetComponents <Component>())
            {
                if (component == editTarget)
                {
                    continue;
                }

                bool componentRecorded = recordedComponentsProperty.ArrayContains(component);
                bool result            = EditorGUILayout.Toggle(component.GetType().Name, componentRecorded);

                if (componentRecorded && !result)
                {
                    recordedComponentsProperty.ArrayDeleteElement(component);
                }
                else if (!componentRecorded && result)
                {
                    recordedComponentsProperty.ArrayAddElement(component);
                }

                i++;
                if (i == numPerRow)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    i = 0;
                }
            }
            EditorGUILayout.EndHorizontal();

            SetBool(false);
            serializedObject.ApplyModifiedProperties();
        }
Exemple #2
0
 bool ParameterLinkExists(string name)
 {
     return(parameterLinksProperty.ArrayContains("Name", p => p.stringValue == name));
 }
Exemple #3
0
 bool InitialParameterValueExists(string name)
 {
     return(parametersProperty.ArrayContains("Name", p => p.stringValue == name));
 }