public void SelectForBakeEffect(bool select) { SteamAudioSource[] bakedSources = GameObject.FindObjectsOfType <SteamAudioSource>(); foreach (SteamAudioSource bakedSource in bakedSources) { if (bakedSource.reflections && bakedSource.uniqueIdentifier.Length != 0 && bakedSource.simulationType == SourceSimulationType.BakedStaticSource) { bakedSource.bakeToggle = select; } } SteamAudioBakedStaticListenerNode[] bakedStaticNodes = GameObject.FindObjectsOfType <SteamAudioBakedStaticListenerNode>(); foreach (SteamAudioBakedStaticListenerNode bakedStaticNode in bakedStaticNodes) { if (bakedStaticNode.uniqueIdentifier.Length != 0) { bakedStaticNode.bakeToggle = select; } } SteamAudioListener bakedReverb = GameObject.FindObjectOfType <SteamAudioListener>(); if (!(bakedReverb == null)) { bakedReverb.bakeToggle = select; } }
public bool BakedReverbGUI(SteamAudioManager phononManager) { SteamAudioListener bakedReverb = GameObject.FindObjectOfType <SteamAudioListener>(); if (bakedReverb == null) { return(false); } EditorGUILayout.LabelField("Baked Reverb", EditorStyles.boldLabel); GUI.enabled = !Baker.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); }
void DisplayProgressBarAndCancel() { SteamAudioListener bakedReverb = serializedObject.targetObject as SteamAudioListener; bakedReverb.phononBaker.DrawProgressBar(); Repaint(); }
public void BakedReverbStatsGUI() { SteamAudioListener bakedReverb = serializedObject.targetObject as SteamAudioListener; GUI.enabled = !Baker.IsBakeActive() && !EditorApplication.isPlayingOrWillChangePlaymode; bakedReverb.UpdateBakedDataStatistics(); for (int i = 0; i < bakedReverb.bakedProbeNames.Count; ++i) { EditorGUILayout.LabelField(bakedReverb.bakedProbeNames[i], (bakedReverb.bakedProbeDataSizes[i] / 1000.0f).ToString("0.0") + " KB"); } EditorGUILayout.LabelField("Total Size", (bakedReverb.bakedDataSize / 1000.0f).ToString("0.0") + " KB"); GUI.enabled = true; }
// // GUI for BakedReverb // public void BakedReverbGUI() { EditorGUILayout.Space(); EditorGUILayout.LabelField("Baked Reverb Settings", EditorStyles.boldLabel); SteamAudioListener bakedReverb = serializedObject.targetObject as SteamAudioListener; GUI.enabled = !Baker.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() { var steamAudioManager = GameObject.FindObjectOfType <SteamAudioManager>(); if (steamAudioManager == null) { EditorGUILayout.HelpBox("A Steam Audio Manager does not exist in the scene. Click Window > Steam" + " Audio.", MessageType.Error); return; } serializedObject.Update(); var staticListenerNodes = GameObject.FindObjectsOfType <SteamAudioBakedStaticListenerNode>(); var staticListenerNodesExist = (staticListenerNodes != null && staticListenerNodes.Length > 0); if (staticListenerNodesExist) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Static Listener Settings", EditorStyles.boldLabel); EditorGUILayout.PropertyField(serializedObject.FindProperty("currentStaticListenerNode")); } BakedReverbGUI(); serializedObject.FindProperty("bakedStatsFoldout").boolValue = EditorGUILayout.Foldout(serializedObject.FindProperty("bakedStatsFoldout").boolValue, "Baked Reverb Statistics"); SteamAudioListener phononListener = serializedObject.targetObject as SteamAudioListener; if (phononListener.bakedStatsFoldout) { BakedReverbStatsGUI(); } serializedObject.ApplyModifiedProperties(); }
public void BakeSelected() { List <GameObject> gameObjects = new List <GameObject>(); List <BakedDataIdentifier> identifers = new List <BakedDataIdentifier>(); List <string> names = new List <string>(); List <Sphere> influenceSpheres = new List <Sphere>(); List <SteamAudioProbeBox[]> probeBoxes = new List <SteamAudioProbeBox[]>(); SteamAudioSource[] bakedSources = GameObject.FindObjectsOfType <SteamAudioSource>(); foreach (SteamAudioSource bakedSource in bakedSources) { if (bakedSource.reflections && bakedSource.uniqueIdentifier.Length != 0 && bakedSource.simulationType == SourceSimulationType.BakedStaticSource && bakedSource.bakeToggle) { gameObjects.Add(bakedSource.gameObject); identifers.Add(bakedSource.bakedDataIdentifier); names.Add(bakedSource.uniqueIdentifier); Sphere bakeSphere; Vector3 sphereCenter = Common.ConvertVector(bakedSource.transform.position); bakeSphere.centerx = sphereCenter.x; bakeSphere.centery = sphereCenter.y; bakeSphere.centerz = sphereCenter.z; bakeSphere.radius = bakedSource.bakingRadius; influenceSpheres.Add(bakeSphere); if (bakedSource.useAllProbeBoxes) { probeBoxes.Add(FindObjectsOfType <SteamAudioProbeBox>() as SteamAudioProbeBox[]); } else { probeBoxes.Add(bakedSource.probeBoxes); } } } SteamAudioBakedStaticListenerNode[] bakedStaticNodes = GameObject.FindObjectsOfType <SteamAudioBakedStaticListenerNode>(); foreach (SteamAudioBakedStaticListenerNode bakedStaticNode in bakedStaticNodes) { if (bakedStaticNode.uniqueIdentifier.Length != 0 && bakedStaticNode.bakeToggle) { gameObjects.Add(bakedStaticNode.gameObject); identifers.Add(bakedStaticNode.bakedDataIdentifier); names.Add(bakedStaticNode.name); Sphere bakeSphere; Vector3 sphereCenter = Common.ConvertVector(bakedStaticNode.transform.position); bakeSphere.centerx = sphereCenter.x; bakeSphere.centery = sphereCenter.y; bakeSphere.centerz = sphereCenter.z; bakeSphere.radius = bakedStaticNode.bakingRadius; influenceSpheres.Add(bakeSphere); if (bakedStaticNode.useAllProbeBoxes) { probeBoxes.Add(FindObjectsOfType <SteamAudioProbeBox>() as SteamAudioProbeBox[]); } else { probeBoxes.Add(bakedStaticNode.probeBoxes); } } } SteamAudioListener bakedReverb = GameObject.FindObjectOfType <SteamAudioListener>(); if (!(bakedReverb == null) && bakedReverb.bakeToggle) { gameObjects.Add(bakedReverb.gameObject); identifers.Add(bakedReverb.Identifier); names.Add("reverb"); influenceSpheres.Add(new Sphere()); if (bakedReverb.useAllProbeBoxes) { probeBoxes.Add(FindObjectsOfType <SteamAudioProbeBox>() as SteamAudioProbeBox[]); } else { probeBoxes.Add(bakedReverb.probeBoxes); } } if (gameObjects.Count > 0) { SteamAudioManager phononManager = serializedObject.targetObject as SteamAudioManager; phononManager.phononBaker.BeginBake(gameObjects.ToArray(), identifers.ToArray(), names.ToArray(), influenceSpheres.ToArray(), probeBoxes.ToArray()); } else { Debug.LogWarning("No game object selected for baking."); } }