Example #1
0
        public override void OnInspectorGUI()
        {
            // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
            editor.serializedObject.Update();

            newDraggedPrefabs = null;

            // draw default inspector elements
            DrawDefaultInspector();

            ///
            /// Version Info
            ///
            EditorGUILayout.HelpBox("Prefab Painter v0.9 (Beta)", MessageType.Info);

            ///
            /// General settings
            ///


            GUILayout.BeginVertical("box");
            {
                EditorGUILayout.LabelField("General Settings", GUIStyles.BoxTitleStyle);

                EditorGUILayout.BeginHorizontal();

                // container
                EditorGUILayout.PrefixLabel("");

                if (this.editorTarget.container == null)
                {
                    editor.SetErrorBackgroundColor();
                }

                EditorGUILayout.PropertyField(container);

                editor.SetDefaultBackgroundColor();

                if (GUILayout.Button("New", EditorStyles.miniButton, GUILayout.Width(50)))
                {
                    GameObject newContainer = new GameObject();

                    string name = editorTarget.name + " Container" + " (" + (this.editorTarget.transform.childCount + 1) + ")";
                    newContainer.name = name;

                    // set parent; reset position & rotation
                    newContainer.transform.SetParent(this.editorTarget.transform, false);

                    // set as new value
                    container.objectReferenceValue = newContainer;
                }

                if (GUILayout.Button("Clear", EditorStyles.miniButton, GUILayout.Width(50)))
                {
                    if (container != null)
                    {
                        this.toolsModule.RemoveContainerChildren();
                    }
                }

                EditorGUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            ///
            /// mode
            ///

            GUILayout.BeginVertical("box");
            {
                EditorGUILayout.LabelField("Mode", GUIStyles.BoxTitleStyle);

                EditorGUILayout.BeginHorizontal();

                EditorGUI.BeginChangeCheck();
                {
                    mode.intValue = GUILayout.Toolbar(mode.intValue, modeButtons);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    brushModule.ModeChanged((PrefabPainter.Mode)mode.intValue);
                }

                EditorGUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            ///
            /// Mode dependent
            ///

            switch (this.editorTarget.mode)
            {
            case PrefabPainter.Mode.Brush:

                brushModule.OnInspectorGUI();

                // spawn
                spawnModule.OnInspectorGUI();

                // filter
                filterModule.OnInspectorGUI();

                /// Prefabs
                this.prefabModule.OnInspectorGUI();

                break;

            case PrefabPainter.Mode.Spline:

                splineModule.OnInspectorGUI();

                // spawn
                if (editorTarget.splineSettings.spawnMechanism == SplineSettings.SpawnMechanism.Manual)
                {
                    spawnModule.OnInspectorGUI();
                }

                /// Prefabs
                this.prefabModule.OnInspectorGUI();

                break;

            case PrefabPainter.Mode.Interaction:

                interactionModule.OnInspectorGUI();

                // spawn
                spawnModule.OnInspectorGUI();

                break;

            case PrefabPainter.Mode.Container:
                containerModule.OnInspectorGUI();

                /// Physics
                this.physicsModule.OnInspectorGUI();

                /// Copy/Paste
                this.copyPasteModule.OnInspectorGUI();

                // Selection
                this.selectionModule.OnInspectorGUI();

                // Tools
                this.toolsModule.OnInspectorGUI();
                break;
            }



            // add new prefabs
            if (newDraggedPrefabs != null)
            {
                this.editorTarget.prefabSettingsList.AddRange(newDraggedPrefabs);
            }

            // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
            editor.serializedObject.ApplyModifiedProperties();
        }