void DisplayProgressBarAndCancel() { BakedSource bakedSource = serializedObject.targetObject as BakedSource; if (bakedSource.bakeStatus != BakeStatus.InProgress) { return; } float progress = bakedSource.probeBoxBakingProgress + .01f; //Adding an offset because progress bar when it is exact 0 has some non-zero progress. int progressPercent = Mathf.FloorToInt(Mathf.Min(progress * 100.0f, 100.0f)); string progressString = "Baking " + bakedSource.probeBoxBakingCurrently + "/" + bakedSource.totalProbeBoxes + " Probe Box (" + progressPercent.ToString() + "% complete)"; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(" "); EditorGUI.ProgressBar(EditorGUILayout.GetControlRect(), progress, progressString); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(" "); if (GUILayout.Button("Cancel Bake")) { bakedSource.cancelBake = true; // Ensures partial baked data is not serialized and that bake is properly cancelled for multiple probe boxes. PhononCore.iplCancelBake(); bakedSource.EndBake(); oneBakeActive = false; bakedSource.cancelBake = false; Debug.Log("CANCELLED: Baking effect for \"" + bakedSource.uniqueIdentifier + "\" with influence radius of " + bakedSource.bakingRadius + " meters."); } EditorGUILayout.EndHorizontal(); Repaint(); }
// // 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(); }
// // Draws the inspector GUI. // public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("useBakedStaticListener")); if (serializedObject.FindProperty("useBakedStaticListener").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("bakedListenerIdentifier")); } else { EditorGUILayout.PropertyField(serializedObject.FindProperty("uniqueIdentifier")); //EditorGUILayout.PropertyField(serializedObject.FindProperty("bakeConvolution")); //EditorGUILayout.PropertyField(serializedObject.FindProperty("bakeParameteric")); EditorGUILayout.PropertyField(serializedObject.FindProperty("bakingRadius")); EditorGUILayout.PropertyField(serializedObject.FindProperty("useAllProbeBoxes")); if (!serializedObject.FindProperty("useAllProbeBoxes").boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("probeBoxes"), true); } BakedSource bakedSource = serializedObject.targetObject as BakedSource; GUI.enabled = !oneBakeActive && !BakedReverbInspector.oneBakeActive && !BakedStaticListenerInspector.oneBakeActive; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(" "); if (GUILayout.Button("Bake Effect")) { Debug.Log("START: Baking effect for \"" + bakedSource.uniqueIdentifier + "\" with influence radius of " + bakedSource.bakingRadius + " meters."); oneBakeActive = true; bakedSource.BeginBake(); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; DisplayProgressBarAndCancel(); if (bakedSource.bakeStatus == BakeStatus.Complete) { bakedSource.EndBake(); oneBakeActive = false; Repaint(); Debug.Log("COMPLETED: Baking effect for \"" + bakedSource.uniqueIdentifier + "\" with influence radius of " + bakedSource.bakingRadius + " meters."); } } serializedObject.ApplyModifiedProperties(); }
// // Courutine to update source and listener position and orientation at frame end. // Done this way to ensure correct update in VR setup. // private IEnumerator EndOfFrameUpdate() { while (true) { if (!initialized && propagationAmbisonicsEffect == IntPtr.Zero && environmentalRenderer != null && environmentalRenderer.GetEnvironmentalRenderer() != IntPtr.Zero && environment != null && environment.Environment().GetEnvironment() != IntPtr.Zero) { // Check for Baked Source or Baked Reverb component. string effectName = ""; if (simulationMode == SimulationType.Baked) { BakedSource bakedSource = GetComponent <BakedSource>(); BakedReverb bakedReverb = GetComponent <BakedReverb>(); if (bakedSource != null) { if (bakedSource.useBakedStaticListener) { effectName = "__staticlistener__" + bakedSource.bakedListenerIdentifier; } else { effectName = bakedSource.uniqueIdentifier; } } if (bakedReverb != null) { effectName = "__reverb__"; } } #if !UNITY_ANDROID if (PhononCore.iplCreateConvolutionEffect(environmentalRenderer.GetEnvironmentalRenderer(), effectName, simulationMode, inputFormat, ambisonicsFormat, ref propagationAmbisonicsEffect) != Error.None) { Debug.LogError("Unable to create propagation effect for object: " + gameObject.name); } #endif initialized = true; } if (!errorLogged && environment != null && environment.Scene().GetScene() == IntPtr.Zero && ((directOcclusionOption != OcclusionOption.None) || enableReflections)) { Debug.LogError("Scene not found. Make sure to pre-export the scene."); errorLogged = true; } if (!initialized && (directOcclusionOption == OcclusionOption.None) && !enableReflections) { initialized = true; } UpdateRelativeDirection(); if (phononMixer && phononMixer.enabled) { fourierMixingEnabled = true; } else { fourierMixingEnabled = false; } yield return(new WaitForEndOfFrame()); // Must yield after updating the relative direction. } }