//
        // 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();
        }
示例#2
0
        //
        // Returns the settings object, creating it if necessary.
        //
        public static GameObject GetObject()
        {
            // The name of the object.
            string name = "Phonon Simulation Settings";

            // If the reference is null, we need to point it to the object.
            if (settingsObject == null)
            {
                // Try finding the object.
                GameObject existingObject = GameObject.Find(name);

                // If the object couldn't be found, we need to create it.
                if (existingObject == null)
                {
                    // Create the object.
                    existingObject = new GameObject(name);

                    // Add a simulation bake settings component.
                    existingObject.AddComponent <SimulationSettings>();
                    SimulationSettings simulationSettings = existingObject.GetComponent <SimulationSettings>();
                    simulationSettings.Value = new SimulationSettingsValue();
                    simulationSettings.Value.CopyFrom(SimulationSettingsPresetList.PresetValue((int)simulationSettings.Preset));
                }

                // Point our reference to the object.
                settingsObject = existingObject;
            }

            // Return the object.
            return(settingsObject);
        }
示例#3
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();
        }
        //
        // 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();
        }