private void MicrophoneGui(DissonanceComms comm) { using (new EditorGUI.DisabledScope(Application.isPlaying)) { var inputString = EditorGUILayout.DelayedTextField("Microphone Device Name", comm.MicrophoneName ?? "None (Default)"); //If the name is any of these special string, default it back to null var nulls = new[] { "null", "(null)", "default", "(default)", "none default", "none (default)", "none", "(none)" }; if (string.IsNullOrEmpty(inputString) || nulls.Contains(inputString, StringComparer.InvariantCultureIgnoreCase)) { inputString = null; } if (!Application.isPlaying && comm.MicrophoneName != inputString) { comm.ChangeWithUndo( "Changed Dissonance Microphone", inputString, comm.MicrophoneName, a => comm.MicrophoneName = a ); } } if (Application.isPlaying) { _micMeter.DrawInspectorGui(comm, (comm.MicCapture == null) ? 0 : comm.MicCapture.Amplitude, comm.IsMuted); } }
private void PlaybackPrefabGui([NotNull] DissonanceComms comm) { using (new EditorGUI.DisabledScope(Application.isPlaying)) { var prefab = EditorGUILayout.ObjectField("Playback Prefab", comm.PlaybackPrefab, typeof(GameObject), false); if (!Application.isPlaying) { // Check if we're in the special case of setting to nothing, when it's already nothing if (prefab == null && comm.PlaybackPrefab == null) { //Display the last error if (!string.IsNullOrEmpty(_lastPrefabError)) { EditorGUILayout.HelpBox(_lastPrefabError, MessageType.Error); } return; } GameObject newPrefab = null; if (prefab == null) { //Setting to null, no error involved with this _lastPrefabError = null; } else if (PrefabUtility.GetPrefabType(prefab) == PrefabType.Prefab) { //Check that the prefab is valid newPrefab = (GameObject)prefab; if (newPrefab.GetComponent <VoicePlayback>() == null) { newPrefab = null; _lastPrefabError = "Playback Prefab must contain a VoicePlayback component"; } else { _lastPrefabError = null; } } else { _lastPrefabError = "Playback Prefab type must be user created prefab asset"; } if (!string.IsNullOrEmpty(_lastPrefabError)) { EditorGUILayout.HelpBox(_lastPrefabError, MessageType.Error); } comm.ChangeWithUndo( "Changed Dissonance Playback Prefab", ReferenceEquals(newPrefab, null) ? null : newPrefab.gameObject, comm.PlaybackPrefab, a => comm.PlaybackPrefab = a ); } } }
private static void PlaybackPrefabGui([NotNull] DissonanceComms comm) { using (new EditorGUI.DisabledScope(Application.isPlaying)) { var prefab = EditorGUILayout.ObjectField("Playback Prefab", comm.PlaybackPrefab, typeof(VoicePlayback), false); if (!Application.isPlaying) { VoicePlayback newPrefab = null; if (prefab != null && PrefabUtility.GetPrefabType(prefab) == PrefabType.Prefab) { newPrefab = (VoicePlayback)prefab; } comm.ChangeWithUndo( "Changed Dissonance Playback Prefab", newPrefab, comm.PlaybackPrefab, a => comm.PlaybackPrefab = a ); } } }