//
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            PhononGUI.SectionHeader("Quality Preset");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("Preset"));

            if (serializedObject.FindProperty("Preset").enumValueIndex < 3)
            {
                SimulationSettingsValue actualValue = ((SimulationSettings)target).Value;
                actualValue.CopyFrom(SimulationSettingsPresetList.PresetValue(serializedObject.FindProperty("Preset").enumValueIndex));
            }
            else
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("Value"));

                if (Application.isEditor && EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    SimulationSettingsValue actualValue = ((SimulationSettings)target).Value;
                    EnvironmentComponent    editorRuntimeEnvComponent = FindObjectOfType <EnvironmentComponent>();
                    if (editorRuntimeEnvComponent != null)
                    {
                        IntPtr environment = editorRuntimeEnvComponent.Environment().GetEnvironment();
                        PhononCore.iplSetNumBounces(environment, actualValue.RealtimeBounces);
                    }
                }
            }

            EditorGUILayout.Space();
            serializedObject.ApplyModifiedProperties();
        }
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            PhononGUI.SectionHeader("Mixer Settings");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("acceleratedMixing"));

            if (!serializedObject.FindProperty("acceleratedMixing").boolValue)
            {
                PhononGUI.SectionHeader("Reverb Settings");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("enableReverb"));

                if (serializedObject.FindProperty("enableReverb").boolValue)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("reverbSimulationType"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("dryMixFraction"));
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("reverbMixFraction"));

                    PhononListener phononListener = serializedObject.targetObject as PhononListener;
                    if (phononListener.reverbSimulationType == ReverbSimulationType.BakedReverb)
                    {
                        BakedReverbGUI();
                    }
                }
            }

            PhononGUI.SectionHeader("Rendering Settings");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectBinauralEnabled"));

            if (serializedObject.FindProperty("acceleratedMixing").boolValue&& serializedObject.FindProperty("indirectBinauralEnabled").boolValue)
            {
                EditorGUILayout.HelpBox("The binaural settings on Phonon Source will be ignored.", MessageType.Info);
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            PhononGeometry geometry = serializedObject.targetObject as PhononGeometry;

            EditorGUILayout.Space();
            bool toggleValue = serializedObject.FindProperty("exportAllChildren").boolValue;

            if (geometry.transform.childCount != 0)
            {
                serializedObject.FindProperty("exportAllChildren").boolValue = GUILayout.Toggle(toggleValue, " Export All Children");
            }

            PhononGUI.SectionHeader("Geometry Statistics");
            EditorGUILayout.LabelField("Vertices", geometry.GetNumVertices().ToString());
            EditorGUILayout.LabelField("Triangles", geometry.GetNumTriangles().ToString());

            if (geometry.gameObject.GetComponent <Terrain>() != null)
            {
                PhononGUI.SectionHeader("Terrain Export Settings");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("TerrainSimplificationLevel"));
            }

            EditorGUILayout.Space();

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #4
0
        public bool ProbeGenerationGUI()
        {
            ProbeBox[] probeBoxes = GameObject.FindObjectsOfType <ProbeBox>();
            if (probeBoxes.Length > 0)
            {
                PhononGUI.SectionHeader("Probe Generation");
            }
            else
            {
                return(false);
            }

            GUI.enabled = !PhononBaker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
            foreach (ProbeBox probeBox in probeBoxes)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(probeBox.name);
                if (GUILayout.Button("Generate Probe", GUILayout.Width(200.0f)))
                {
                    probeBox.GenerateProbes();
                    EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                }
                EditorGUILayout.EndHorizontal();
            }
            GUI.enabled = true;

            return(true);
        }
Beispiel #5
0
        //
        // GUI for BakedReverb
        //
        public void BakedReverbGUI()
        {
            PhononGUI.SectionHeader("Baked Reverb Settings");

            PhononListener bakedReverb = serializedObject.targetObject as PhononListener;

            GUI.enabled = !bakedReverb.phononBaker.IsBakeActive();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useAllProbeBoxes"));
            if (!serializedObject.FindProperty("useAllProbeBoxes").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("probeBoxes"), true);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            if (GUILayout.Button("Bake Reverb"))
            {
                Debug.Log("START: Baking reverb effect.");
                bakedReverb.BeginBake();
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            DisplayProgressBarAndCancel();

            if (bakedReverb.phononBaker.GetBakeStatus() == BakeStatus.Complete)
            {
                bakedReverb.EndBake();
                Repaint();
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                Debug.Log("COMPLETED: Baking reverb effect.");
            }
        }
        public static void DrawPane()
        {
            if (targetObject == null || editor == null)
            {
                targetObject = PhononMaterialSettings.GetObject();
                editor       = Editor.CreateEditor(targetObject.GetComponent <PhononMaterial>());
            }

            editor.OnInspectorGUI();

            PhononGUI.SectionHeader("Export Phonon Geometry");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");

            if (GUILayout.Button("Export to OBJ"))
            {
                EnvironmentComponent.DumpScene();
            }

            if (GUILayout.Button("Pre-Export Scene"))
            {
                EnvironmentComponent.ExportScene();
            }

            EditorGUILayout.EndHorizontal();
        }
Beispiel #7
0
        public bool BakedReverbGUI(PhononManager phononManager)
        {
            PhononListener bakedReverb = GameObject.FindObjectOfType <PhononListener>();

            if (bakedReverb == null || !bakedReverb.enableReverb ||
                bakedReverb.reverbSimulationType != ReverbSimulationType.BakedReverb)
            {
                return(false);
            }

            PhononGUI.SectionHeader("Bake Reverb");

            GUI.enabled = !PhononBaker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
            EditorGUILayout.BeginHorizontal();
            bakedReverb.UpdateBakedDataStatistics();

            bool previousValues = bakedReverb.bakeToggle;
            bool newValue       = GUILayout.Toggle(bakedReverb.bakeToggle, " reverb");

            if (previousValues != newValue)
            {
                Undo.RecordObject(bakedReverb, "Toggled reverb in Phonon Manager");
                bakedReverb.bakeToggle = newValue;
            }

            EditorGUILayout.LabelField((bakedReverb.bakedDataSize / 1000.0f).ToString("0.0") + " KB");
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            return(true);
        }
        public bool ProbeGenerationGUI()
        {
            ProbeBox[] probeBoxes = GameObject.FindObjectsOfType <ProbeBox>();
            if (probeBoxes.Length > 0)
            {
                PhononGUI.SectionHeader("Probe Generation");
            }
            else
            {
                return(false);
            }

            foreach (ProbeBox probeBox in probeBoxes)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(probeBox.name);
                if (GUILayout.Button("Generate Probe", GUILayout.Width(200.0f)))
                {
                    probeBox.GenerateProbes();
                }
                EditorGUILayout.EndHorizontal();
            }

            return(true);
        }
        //
        // Draws the inspector GUI.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            string[] placementStrategyString   = { "Centroid", "Uniform Floor" };
            var      placementStrategyProperty = serializedObject.FindProperty("placementStrategy");
            int      enumValueIndex            = (placementStrategyProperty.enumValueIndex > 0) ? 1 : 0;

            enumValueIndex = EditorGUILayout.Popup("Placement Strategy", enumValueIndex, placementStrategyString);
            placementStrategyProperty.enumValueIndex = (enumValueIndex > 0) ? 2 : 0;

            if (serializedObject.FindProperty("placementStrategy").intValue == (int)ProbePlacementStrategy.Octree)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("maxNumTriangles"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("maxOctreeDepth"));
            }
            else if (serializedObject.FindProperty("placementStrategy").intValue == (int)ProbePlacementStrategy.UniformFloor)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("horizontalSpacing"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("heightAboveFloor"));
            }

            ProbeBox probeBox = serializedObject.targetObject as ProbeBox;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            if (GUILayout.Button("Generate Probes"))
            {
                probeBox.GenerateProbes();
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }
            EditorGUILayout.EndHorizontal();

            if (probeBox.probeSpherePoints != null && probeBox.probeSpherePoints.Length != 0)
            {
                PhononGUI.SectionHeader("Probe Box Statistics");
                EditorGUILayout.LabelField("Probe Points", (probeBox.probeSpherePoints.Length / 3).ToString());
                EditorGUILayout.LabelField("Probe Data Size", (probeBox.probeBoxData.Length / 1000.0f).ToString("0.0") + " KB");
            }

            for (int i = 0; i < probeBox.probeDataName.Count; ++i)
            {
                if (i == 0)
                {
                    PhononGUI.SectionHeader("Detailed Statistics");
                }

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(probeBox.probeDataName[i], (probeBox.probeDataNameSizes[i] / 1000.0f).ToString("0.0") + " KB");
                if (GUILayout.Button("Clear"))
                {
                    probeBox.DeleteBakedDataByName(probeBox.probeDataName[i]);
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #10
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.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Direct Sound UX
            PhononGUI.SectionHeader("Direct Sound");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("directBinauralEnabled"));
            if (serializedObject.FindProperty("directBinauralEnabled").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("hrtfInterpolation"), new GUIContent("HRTF Interpolation"));
            }

            serializedObject.FindProperty("directOcclusionMode").enumValueIndex = EditorGUILayout.Popup("Direct Sound Occlusion", serializedObject.FindProperty("directOcclusionMode").enumValueIndex, optionsOcclusion);
            if (serializedObject.FindProperty("directOcclusionMode").enumValueIndex != (int)OcclusionMode.NoOcclusion)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("directOcclusionMethod"));
                if (serializedObject.FindProperty("directOcclusionMethod").enumValueIndex == (int)OcclusionMethod.Partial)
                {
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("partialOcclusionRadius"), new GUIContent("Source Radius (meters)"));
                }
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("physicsBasedAttenuation"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("airAbsorption"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("directMixFraction"));

            // Indirect Sound UX
            PhononGUI.SectionHeader("Reflected Sound");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("enableReflections"));

            if (serializedObject.FindProperty("enableReflections").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("sourceSimulationType"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectMixFraction"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectBinauralEnabled"));

                EditorGUILayout.HelpBox("Go to Window > Phonon > Simulation to update the global simulation settings.", MessageType.Info);
                if (serializedObject.FindProperty("indirectBinauralEnabled").boolValue)
                {
                    EditorGUILayout.HelpBox("The binaural setting is ignored if Phonon Listener component is attached with mixing enabled.", MessageType.Info);
                }

                PhononSource phononEffect = serializedObject.targetObject as PhononSource;
                if (phononEffect.sourceSimulationType == SourceSimulationType.BakedStaticSource)
                {
                    BakedSourceGUI();
                    bakedStatsFoldout = EditorGUILayout.Foldout(bakedStatsFoldout, "Baked Static Source Statistics");
                    if (bakedStatsFoldout)
                    {
                        BakedSourceStatsGUI();
                    }
                }
            }

            // Save changes.
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #12
0
        public bool BakedSourcesGUI(PhononManager phononManager)
        {
            PhononSource[] bakedSources = GameObject.FindObjectsOfType <PhononSource>();

            bool showBakedSources = false;

            foreach (PhononSource bakedSource in bakedSources)
            {
                if (bakedSource.enableReflections && bakedSource.uniqueIdentifier.Length != 0 &&
                    bakedSource.sourceSimulationType == SourceSimulationType.BakedStaticSource)
                {
                    showBakedSources = true;
                    break;
                }
            }

            if (showBakedSources)
            {
                PhononGUI.SectionHeader("Baked Sources");
            }
            else
            {
                return(false);
            }

            foreach (PhononSource bakedSource in bakedSources)
            {
                if (!bakedSource.enableReflections || bakedSource.uniqueIdentifier.Length == 0 ||
                    bakedSource.sourceSimulationType != SourceSimulationType.BakedStaticSource)
                {
                    continue;
                }

                GUI.enabled = !PhononBaker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
                EditorGUILayout.BeginHorizontal();

                bakedSource.UpdateBakedDataStatistics();
                bool previousValue = bakedSource.bakeToggle;
                bool newValue      = GUILayout.Toggle(bakedSource.bakeToggle, " " + bakedSource.uniqueIdentifier);
                if (previousValue != newValue)
                {
                    Undo.RecordObject(bakedSource, "Toggled " + bakedSource.uniqueIdentifier +
                                      " in Phonon Manager");
                    bakedSource.bakeToggle = newValue;
                }

                EditorGUILayout.LabelField((bakedSource.bakedDataSize / 1000.0f).ToString("0.0") + " KB");
                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;
            }

            return(true);
        }
        //
        // 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();
        }
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Direct Sound UX
            PhononGUI.SectionHeader("Direct Sound");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("directBinauralEnabled"));
            if (serializedObject.FindProperty("directBinauralEnabled").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("hrtfInterpolation"), new GUIContent("HRTF Interpolation"));
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("directOcclusionOption"));
            if (serializedObject.FindProperty("directOcclusionOption").enumValueIndex == (int)OcclusionOption.Partial)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("partialOcclusionRadius"), new GUIContent("Source Radius (meters)"));
            }

            EditorGUILayout.PropertyField(serializedObject.FindProperty("physicsBasedAttenuation"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("directMixFraction"));

            // Indirect Sound UX
            PhononGUI.SectionHeader("Reflected Sound");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("enableReflections"));

            if (serializedObject.FindProperty("enableReflections").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("simulationMode"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectMixFraction"));
                //EditorGUILayout.PropertyField(serializedObject.FindProperty("diffractionEnabled"));
                EditorGUILayout.PropertyField(serializedObject.FindProperty("indirectBinauralEnabled"));

                if (serializedObject.FindProperty("indirectBinauralEnabled").boolValue)
                {
                    EditorGUILayout.HelpBox("The binaural setting is ignored if Phonon Mixer component is attached to Audio Listener.", MessageType.Info);
                }

                EditorGUILayout.HelpBox("Go to Windows > Phonon > Simulation to update the global baking simulation settings.", MessageType.Info);
                PhononEffect phononEffect = serializedObject.targetObject as PhononEffect;

                BakedSource bakedSource        = phononEffect.GetComponent <BakedSource>();
                BakedReverb bakedReverb        = phononEffect.GetComponent <BakedReverb>();
                bool        bakeSimulationMode = (phononEffect.simulationMode == SimulationType.Baked);
                if (bakeSimulationMode && bakedSource == null && bakedReverb == null)
                {
                    EditorGUILayout.HelpBox("Make sure to add a Baked Source or a Baked Reverb component when using bake simulation for reflection sound.", MessageType.Error);
                }
            }

            // Save changes.
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #15
0
        public void BakedSourceGUI()
        {
            PhononGUI.SectionHeader("Baked Static Source Settings");

            PhononSource bakedSource = serializedObject.targetObject as PhononSource;

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

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

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

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

            DisplayProgressBarAndCancel();

            if (bakedSource.phononBaker.GetBakeStatus() == BakeStatus.Complete)
            {
                bakedSource.EndBake();
                Repaint();
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                Debug.Log("COMPLETED: Baking effect for \"" + bakedSource.uniqueIdentifier + "\" with influence radius of " + bakedSource.bakingRadius + " meters.");
            }
        }
Beispiel #16
0
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            PhononGUI.SectionHeader("Audio Engine Integration");

            string[] engines             = { "Unity Audio" };
            var      audioEngineProperty = serializedObject.FindProperty("audioEngine");

            audioEngineProperty.enumValueIndex = EditorGUILayout.Popup("Audio Engine", audioEngineProperty.enumValueIndex, engines);

            EditorGUILayout.Space();

            serializedObject.ApplyModifiedProperties();
        }
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            PhononGUI.SectionHeader("Simulation Setting");
            serializedObject.FindProperty("rayTracerOption").enumValueIndex = EditorGUILayout.Popup("Raytracer Options", serializedObject.FindProperty("rayTracerOption").enumValueIndex, optionsRayTracer);

            PhononGUI.SectionHeader("Renderer Setting");
            serializedObject.FindProperty("convolutionOption").enumValueIndex = EditorGUILayout.Popup("Convolution Options", serializedObject.FindProperty("convolutionOption").enumValueIndex, optionsConvolution);

            PhononGUI.SectionHeader("OpenCL Setting");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useOpenCL"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("computeDeviceOption"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("numComputeUnits"));

            EditorGUILayout.HelpBox("This is an experimental feature. Please contact the developers to get relevant documentation to use Custom Phonon Settings feature.", MessageType.Info);
            serializedObject.ApplyModifiedProperties();
        }
        public bool BakedStaticListenerNodeGUI(PhononManager phononManager)
        {
            BakedStaticListenerNode[] bakedStaticNodes = GameObject.FindObjectsOfType <BakedStaticListenerNode>();

            if (bakedStaticNodes.Length > 0)
            {
                PhononGUI.SectionHeader("Baked Static Listener Nodes");
            }
            else
            {
                return(false);
            }

            foreach (BakedStaticListenerNode bakedStaticNode in bakedStaticNodes)
            {
                if (bakedStaticNode.uniqueIdentifier.Length == 0)
                {
                    continue;
                }

                GUI.enabled = !bakedStaticNode.phononBaker.IsBakeActive();
                EditorGUILayout.BeginHorizontal();
                bakedStaticNode.UpdateBakedDataStatistics();
                EditorGUILayout.LabelField("__staticlistener__" + bakedStaticNode.uniqueIdentifier, (bakedStaticNode.bakedDataSize / 1000.0f).ToString("0.0") + " KB");
                if (GUILayout.Button("Bake Effect", GUILayout.Width(200.0f)))
                {
                    phononManager.currentlyBakingObject = bakedStaticNode;
                    Debug.Log("START: Baking effect for \"" + bakedStaticNode.uniqueIdentifier + "\".");
                    bakedStaticNode.BeginBake();
                }
                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;

                DisplayProgressBarAndCancel(bakedStaticNode, phononManager);

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

            return(true);
        }
        public void BakedSourceGUI()
        {
            PhononGUI.SectionHeader("Baked Static Source Settings");

            PhononSource bakedSource = serializedObject.targetObject as PhononSource;

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

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

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

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

            DisplayProgressBarAndCancel();
        }
Beispiel #20
0
        public bool BakeAllGUI()
        {
            bool hasBakeComponents = GameObject.FindObjectsOfType <ProbeBox>().Length > 0;

            if (hasBakeComponents)
            {
                PhononGUI.SectionHeader("Bake All");
            }
            else
            {
                return(false);
            }

            GUI.enabled = !PhononBaker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Select All"))
            {
                SelectForBakeEffect(true);
            }

            if (GUILayout.Button("Select None"))
            {
                SelectForBakeEffect(false);
            }

            if (GUILayout.Button("Bake", GUILayout.Width(200.0f)))
            {
                BakeSelected();
            }

            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            DisplayProgressBarAndCancel();

            return(true);
        }
Beispiel #21
0
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            PhononGUI.SectionHeader("Material Preset");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("Preset"));

            if (serializedObject.FindProperty("Preset").enumValueIndex < 11)
            {
                PhononMaterialValue actualValue = ((PhononMaterial)target).Value;
                actualValue.CopyFrom(PhononMaterialPresetList.PresetValue(serializedObject.FindProperty("Preset").enumValueIndex));
            }
            else
            {
                PhononGUI.SectionHeader("Custom Material");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("Value"));
            }

            EditorGUILayout.Space();

            // Save changes.
            serializedObject.ApplyModifiedProperties();
        }
        public bool BakedReverbGUI(PhononManager phononManager)
        {
            PhononListener bakedReverb = GameObject.FindObjectOfType <PhononListener>();

            if (bakedReverb == null || !bakedReverb.enableReverb ||
                bakedReverb.reverbSimulationType != ReverbSimulationType.BakedReverb)
            {
                return(false);
            }

            PhononGUI.SectionHeader("Bake Reverb");

            GUI.enabled = !bakedReverb.phononBaker.IsBakeActive();
            EditorGUILayout.BeginHorizontal();
            bakedReverb.UpdateBakedDataStatistics();
            EditorGUILayout.LabelField("__reverb__", (bakedReverb.bakedDataSize / 1000.0f).ToString("0.0") + " KB");
            if (GUILayout.Button("Bake Reverb", GUILayout.Width(200.0f)))
            {
                Debug.Log("START: Baking reverb effect.");
                phononManager.currentlyBakingObject = bakedReverb;
                bakedReverb.BeginBake();
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            DisplayProgressBarAndCancel(bakedReverb, phononManager);

            if (bakedReverb.phononBaker.GetBakeStatus() == BakeStatus.Complete)
            {
                bakedReverb.EndBake();
                phononManager.currentlyBakingObject = null;
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                Debug.Log("COMPLETED: Baking reverb effect.");
            }

            return(true);
        }
        //
        // GUI for BakedReverb
        //
        public void BakedReverbGUI()
        {
            PhononGUI.SectionHeader("Baked Reverb Settings");

            PhononListener bakedReverb = serializedObject.targetObject as PhononListener;

            GUI.enabled = !PhononBaker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode;
            EditorGUILayout.PropertyField(serializedObject.FindProperty("useAllProbeBoxes"));
            if (!serializedObject.FindProperty("useAllProbeBoxes").boolValue)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("probeBoxes"), true);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");
            if (GUILayout.Button("Bake Reverb"))
            {
                bakedReverb.BeginBake();
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;

            DisplayProgressBarAndCancel();
        }
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Audio Engine
            PhononGUI.SectionHeader("Audio Engine Integration");
            string[] engines             = { "Unity Audio" };
            var      audioEngineProperty = serializedObject.FindProperty("audioEngine");

            audioEngineProperty.enumValueIndex = EditorGUILayout.Popup("Audio Engine", audioEngineProperty.enumValueIndex, engines);

            // Scene Settings
            PhononManager phononManager = ((PhononManager)target);

            PhononGUI.SectionHeader("Global Material Settings");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("materialPreset"));
            if (serializedObject.FindProperty("materialPreset").enumValueIndex < 11)
            {
                PhononMaterialValue actualValue = phononManager.materialValue;
                actualValue.CopyFrom(PhononMaterialPresetList.PresetValue(serializedObject.FindProperty("materialPreset").enumValueIndex));
            }
            else
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("materialValue"));
            }

            PhononGUI.SectionHeader("Scene Export");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");

            if (GUILayout.Button("Export to OBJ"))
            {
                phononManager.ExportScene(true);
            }
            if (GUILayout.Button("Pre-Export Scene"))
            {
                phononManager.ExportScene(false);
            }

            EditorGUILayout.EndHorizontal();

            // Simulation Settings
            PhononGUI.SectionHeader("Simulation Settings");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("simulationPreset"));
            if (serializedObject.FindProperty("simulationPreset").enumValueIndex < 3)
            {
                SimulationSettingsValue actualValue = phononManager.simulationValue;
                actualValue.CopyFrom(SimulationSettingsPresetList.PresetValue(serializedObject.FindProperty("simulationPreset").enumValueIndex));
            }
            else
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("simulationValue"));
                if (Application.isEditor && EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    SimulationSettingsValue actualValue = phononManager.simulationValue;
                    IntPtr environment = phononManager.PhononManagerContainer().Environment().GetEnvironment();
                    if (environment != IntPtr.Zero)
                    {
                        PhononCore.iplSetNumBounces(environment, actualValue.RealtimeBounces);
                    }
                }
            }

            // Fold Out for Advanced Settings
            PhononGUI.SectionHeader("Advanced Options");
            phononManager.showLoadTimeOptions = EditorGUILayout.Foldout(phononManager.showLoadTimeOptions, "Per Frame Query Optimization");
            if (phononManager.showLoadTimeOptions)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("updateComponents"));
            }

            phononManager.showMassBakingOptions = EditorGUILayout.Foldout(phononManager.showMassBakingOptions, "Consolidated Baking Options");
            if (phononManager.showMassBakingOptions)
            {
                bool noSettingMessage = false;
                noSettingMessage = ProbeGenerationGUI() || noSettingMessage;
                noSettingMessage = BakedSourcesGUI(phononManager) || noSettingMessage;
                noSettingMessage = BakedReverbGUI(phononManager) || noSettingMessage;
                noSettingMessage = BakedStaticListenerNodeGUI(phononManager) || noSettingMessage;

                if (!noSettingMessage)
                {
                    EditorGUILayout.LabelField("Scene does not contain any baking related components.");
                }
            }

            EditorGUILayout.HelpBox("Do not manually add Phonon Manager component. Click Window > Phonon.", MessageType.Info);

            EditorGUILayout.Space();
            serializedObject.ApplyModifiedProperties();
        }
        public bool BakedSourcesGUI(PhononManager phononManager)
        {
            PhononSource[] bakedSources = GameObject.FindObjectsOfType <PhononSource>();

            bool showBakedSources = false;

            foreach (PhononSource bakedSource in bakedSources)
            {
                if (bakedSource.enableReflections && bakedSource.uniqueIdentifier.Length != 0 &&
                    bakedSource.sourceSimulationType == SourceSimulationType.BakedStaticSource)
                {
                    showBakedSources = true;
                    break;
                }
            }

            if (showBakedSources)
            {
                PhononGUI.SectionHeader("Baked Sources");
            }
            else
            {
                return(false);
            }

            foreach (PhononSource bakedSource in bakedSources)
            {
                if (!bakedSource.enableReflections || bakedSource.uniqueIdentifier.Length == 0 ||
                    bakedSource.sourceSimulationType != SourceSimulationType.BakedStaticSource)
                {
                    continue;
                }

                GUI.enabled = !bakedSource.phononBaker.IsBakeActive();
                EditorGUILayout.BeginHorizontal();

                bakedSource.UpdateBakedDataStatistics();
                EditorGUILayout.LabelField(bakedSource.uniqueIdentifier, (bakedSource.bakedDataSize / 1000.0f).ToString("0.0") + " KB");
                if (GUILayout.Button("Bake Effect", GUILayout.Width(200.0f)))
                {
                    phononManager.currentlyBakingObject = bakedSource;
                    Debug.Log("START: Baking effect for \"" + bakedSource.uniqueIdentifier + "\" with influence radius of "
                              + bakedSource.bakingRadius + " meters.");
                    bakedSource.BeginBake();
                }
                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;

                DisplayProgressBarAndCancel(bakedSource, phononManager);

                if (bakedSource.phononBaker.GetBakeStatus() == BakeStatus.Complete)
                {
                    bakedSource.EndBake();
                    phononManager.currentlyBakingObject = null;
                    EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                    Debug.Log("COMPLETED: Baking effect for \"" + bakedSource.uniqueIdentifier + "\" with influence radius of "
                              + bakedSource.bakingRadius + " meters.");
                }
            }

            return(true);
        }
Beispiel #26
0
        //
        // Draws the inspector.
        //
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            // Audio Engine
            PhononGUI.SectionHeader("Audio Engine Integration");
            string[] engines             = { "Unity Audio" };
            var      audioEngineProperty = serializedObject.FindProperty("audioEngine");

            audioEngineProperty.enumValueIndex = EditorGUILayout.Popup("Audio Engine", audioEngineProperty.enumValueIndex, engines);

            // Scene Settings
            PhononManager phononManager = ((PhononManager)target);

            PhononGUI.SectionHeader("Global Material Settings");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("materialPreset"));
            if (serializedObject.FindProperty("materialPreset").enumValueIndex < 11)
            {
                PhononMaterialValue actualValue = phononManager.materialValue;
                actualValue.CopyFrom(PhononMaterialPresetList.PresetValue(serializedObject.FindProperty("materialPreset").enumValueIndex));
            }
            else
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("materialValue"));
            }

            PhononGUI.SectionHeader("Scene Export");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(" ");

            bool exportOBJ   = false;
            bool exportScene = false;

            if (GUILayout.Button("Export to OBJ"))
            {
                exportOBJ = true;
            }
            if (GUILayout.Button("Pre-Export Scene"))
            {
                exportScene = true;
            }

            if (exportOBJ || exportScene)
            {
                if (exportScene)
                {
                    phononManager.ExportScene();
                }
                if (exportOBJ)
                {
                    phononManager.DumpScene();
                }
            }
            EditorGUILayout.EndHorizontal();

            // Simulation Settings
            PhononGUI.SectionHeader("Simulation Settings");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("simulationPreset"));
            if (serializedObject.FindProperty("simulationPreset").enumValueIndex < 3)
            {
                SimulationSettingsValue actualValue = phononManager.simulationValue;
                actualValue.CopyFrom(SimulationSettingsPresetList.PresetValue(serializedObject.FindProperty("simulationPreset").enumValueIndex));
            }
            else
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("simulationValue"));
                if (Application.isEditor && EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    SimulationSettingsValue actualValue = phononManager.simulationValue;
                    IntPtr environment = phononManager.PhononManagerContainer().Environment().GetEnvironment();
                    if (environment != IntPtr.Zero)
                    {
                        PhononCore.iplSetNumBounces(environment, actualValue.RealtimeBounces);
                    }
                }
            }

            EditorGUILayout.Space();
            serializedObject.ApplyModifiedProperties();
        }