Exemplo n.º 1
0
        //
        // Draws the inspector GUI.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            PhononGUI.SectionHeader("Baked Static Listener Settings");

            BakedStaticListenerNode bakedStaticListener = serializedObject.targetObject as BakedStaticListenerNode;

            GUI.enabled = !bakedStaticListener.phononBaker.IsBakeActive();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("uniqueIdentifier"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("bakingRadius"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useAllProbeBoxes"));

            bakedStaticListener.uniqueIdentifier = bakedStaticListener.uniqueIdentifier.Trim();
            if (bakedStaticListener.uniqueIdentifier.Length == 0)
            {
                EditorGUILayout.HelpBox("You must specify a unique identifier name.", MessageType.Warning);
            }

            if (!serializedObject.FindProperty("useAllProbeBoxes").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("probeBoxes"), true);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            if (GUILayout.Button("Bake Effect"))
            {
                if (bakedStaticListener.uniqueIdentifier.Length == 0)
                {
                    Debug.LogError("You must specify a unique identifier name.");
                }
                else
                {
                    Debug.Log("START: Baking effect for \"" + bakedStaticListener.uniqueIdentifier + "\".");
                    bakedStaticListener.BeginBake();
                }
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            DisplayProgressBarAndCancel();

            if (bakedStaticListener.phononBaker.GetBakeStatus() == BakeStatus.Complete)
            {
                bakedStaticListener.EndBake();
                Repaint();
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                Debug.Log("COMPLETED: Baking effect for \"" + bakedStaticListener.uniqueIdentifier + "\".");
            }

            bakedStatsFoldout = EditorGUILayout.Foldout(bakedStatsFoldout, "Baked Static Listener Node Statistics", true);
            if (bakedStatsFoldout)
            {
                BakedStaticListenerNodeStatsGUI();
            }
            serializedObject.ApplyModifiedProperties();
        }
        //
        // Draws the inspector GUI.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            PhononGUI.SectionHeader("Baked Static Listener Settings");

            BakedStaticListenerNode bakedStaticListener =
                serializedObject.targetObject as BakedStaticListenerNode;

            GUI.enabled = !PhononBaker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
            EditorGUILayout.PropertyField(serializedObject.FindProperty("uniqueIdentifier"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("bakingRadius"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useAllProbeBoxes"));

            bakedStaticListener.uniqueIdentifier = bakedStaticListener.uniqueIdentifier.Trim();
            if (bakedStaticListener.uniqueIdentifier.Length == 0)
            {
                EditorGUILayout.HelpBox("You must specify a unique identifier name.", MessageType.Warning);
            }

            if (!serializedObject.FindProperty("useAllProbeBoxes").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("probeBoxes"), true);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            if (GUILayout.Button("Bake Effect"))
            {
                if (bakedStaticListener.uniqueIdentifier.Length == 0)
                {
                    Debug.LogError("You must specify a unique identifier name.");
                }
                else
                {
                    bakedStaticListener.BeginBake();
                }
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            DisplayProgressBarAndCancel();

            serializedObject.FindProperty("bakedStatsFoldout").boolValue =
                EditorGUILayout.Foldout(serializedObject.FindProperty("bakedStatsFoldout").boolValue,
                                        "Baked Static Listener Node Statistics");
            if (bakedStaticListener.bakedStatsFoldout)
            {
                BakedStaticListenerNodeStatsGUI();
            }
            serializedObject.ApplyModifiedProperties();
        }