public override void OnInspectorGUI() { if (DEBUG_MODE) { DrawDefaultInspector(); } else { if (!AudioManagerSettingsEditor.IsOpen) { if (GUILayout.Button("Open Audio Manager Settings")) { AudioManagerSettingsEditor.Init(); } } } }
public override void OnInspectorGUI() { serializedObject.Update(); List <string> excludedProperties = new List <string> { "m_Script" }; GUIContent blontent; //if (!showAdvancedSettings) //{ // excludedProperties.AddRange(new List<string> // { // // }); // // blontent = new GUIContent("↓ Show Advanced Settings ↓", "Toggle this if you're an experienced Unity user"); //} //else //{ // blontent = new GUIContent("↑ Hide Advanced Settings ↑", "Toggle this if you're an experienced Unity user"); //} excludedProperties.AddRange(new List <string> { "listener", "sourcePrefab" }); //if (GUILayout.Button(blontent)) //{ // showAdvancedSettings = !showAdvancedSettings; //} //EditorGUILayout.Space(); blontent = new GUIContent("Volume Controls", "Change the volume levels of all AudioManager-controlled audio channels here"); showVolumeSettings = EditorCompatability.SpecialFoldouts(showVolumeSettings, blontent); if (showVolumeSettings) { DrawAdvancedVolumeControls(myScript); } EditorCompatability.EndSpecialFoldoutGroup(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); blontent = new GUIContent("Library"); EditorGUI.BeginChangeCheck(); libraryIndex = EditorGUILayout.Popup(blontent, libraryIndex, AudioLibraryEditor.projectLibrariesNames.ToArray()); if (EditorGUI.EndChangeCheck()) { library.objectReferenceValue = AudioLibraryEditor.projectLibraries[libraryIndex]; } blontent = new GUIContent(" Open "); if (GUILayout.Button(blontent, new GUILayoutOption[] { GUILayout.ExpandWidth(false) })) { AudioLibraryEditor.Init(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); blontent = new GUIContent("Settings"); EditorGUILayout.PropertyField(settings); blontent = new GUIContent(" Open "); if (GUILayout.Button(blontent, new GUILayoutOption[] { GUILayout.ExpandWidth(false) })) { AudioManagerSettingsEditor.Init(); } EditorGUILayout.EndHorizontal(); DrawPropertiesExcluding(serializedObject, excludedProperties.ToArray()); //if (myScript.GetListenerInternal() == null || showAdvancedSettings) { EditorGUILayout.PropertyField(listener); } #region Source Prefab Helper if (!myScript.SourcePrefabExists()) { EditorGUILayout.PropertyField(sourcePrefab); EditorGUILayout.HelpBox("Reference to Source Prefab is missing! This prefab is required to make " + "AudioManager function. Click the button below to have AudioManager reapply the default reference.", MessageType.Warning); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Reapply Default AudioSource Prefab")) { string[] GUIDs = AssetDatabase.FindAssets("Audio Channel t:GameObject"); GameObject fallback = null; foreach (string s in GUIDs) { GameObject theObject = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(s), typeof(GameObject)) as GameObject; if (theObject.GetComponent <AudioSource>()) { fallback = theObject; break; } } if (fallback != null) // Check has succeeded in finding the default reference { sourcePrefab.objectReferenceValue = fallback; } else // Check has failed to turn up results { GameObject newPrefab = new GameObject("Audio Channel"); AudioSource theSource = newPrefab.AddComponent <AudioSource>(); theSource.rolloffMode = AudioRolloffMode.Logarithmic; theSource.minDistance = 0.5f; theSource.maxDistance = 7; newPrefab.AddComponent <AudioChannelHelper>(); // Look for AudioManager so we can put the new prefab next to it string assetPath = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("Audio Manager t:GameObject")[0]); assetPath = assetPath.Substring(0, assetPath.LastIndexOf("/") + 1); assetPath += "Audio Channel.prefab"; bool success = false; PrefabUtility.SaveAsPrefabAsset(newPrefab, assetPath, out success); if (success) { sourcePrefab.objectReferenceValue = newPrefab; EditorUtility.DisplayDialog("Success", "AudioManager's default source prefab was missing. So a new one was recreated in it's place. " + "If AudioManager doesn't immediately update with the Audio Source prefab in place, click the button again or recompile your code.", "OK"); } DestroyImmediate(newPrefab); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else if (myScript.SourcePrefabExists() /* && showAdvancedSettings*/) { EditorGUILayout.PropertyField(sourcePrefab); } #endregion EditorGUILayout.Space(); if (serializedObject.hasModifiedProperties) { serializedObject.ApplyModifiedProperties(); } if (myScript.GetMasterVolumeInternal() == 0) { EditorGUILayout.HelpBox("Note: Master Volume is set to 0!", MessageType.Info); } if (myScript.GetSoundVolumeInternal() == 0) { EditorGUILayout.HelpBox("Note: Sound is set to 0!", MessageType.Info); } if (myScript.GetMusicVolumeInternal() == 0) { EditorGUILayout.HelpBox("Note: Music is set to 0!", MessageType.Info); } #region Quick Reference Guide showHowTo = EditorCompatability.SpecialFoldouts(showHowTo, "Quick Reference Guide"); if (showHowTo) { JSAMEditorHelper.RenderHelpbox("Overview"); JSAMEditorHelper.RenderHelpbox("This component is the backbone of the entire JSAM Audio Manager system and ideally should occupy it's own gameobject."); JSAMEditorHelper.RenderHelpbox("Remember to mouse over the various menu options in this and other JSAM windows to learn more about them!"); JSAMEditorHelper.RenderHelpbox("Please ensure that you don't have multiple AudioManagers in one scene."); JSAMEditorHelper.RenderHelpbox( "If you have any questions, suggestions or bug reports, feel free to open a new issue " + "on Github repository's Issues page or send me an email directly!" ); EditorGUILayout.Space(); JSAMEditorHelper.RenderHelpbox("Tips"); JSAMEditorHelper.RenderHelpbox( "The Github Repository is usually more up to date with bug fixes " + "than what's shown on the Unity Asset Store, so give it a look just in case!" ); JSAMEditorHelper.RenderHelpbox( "Here are some helpful links, more of which can be found under\nWindows -> JSAM -> JSAM Startup" ); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Report a Bug", "Click on me to go to the bug report page in a new browser window"), new GUILayoutOption[] { GUILayout.MinWidth(100) })) { Application.OpenURL("https://github.com/jackyyang09/Simple-Unity-Audio-Manager/issues"); } GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Github Releases", "Click on me to check out the latest releases in a new browser window"), new GUILayoutOption[] { GUILayout.MinWidth(100) })) { Application.OpenURL("https://github.com/jackyyang09/Simple-Unity-Audio-Manager/releases"); } GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Email", "You can find me at [email protected]"), new GUILayoutOption[] { GUILayout.MinWidth(100) })) { Application.OpenURL("mailto:[email protected]"); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); } EditorCompatability.EndSpecialFoldoutGroup(); #endregion }