private void RemoveSound() { SoundCollection.Remove(SelectedSound); }
public override void OnInspectorGUI() { DrawDefaultInspector(); SoundCollection mycollection = (SoundCollection)target; if (GUILayout.Button("Add New Sound")) { mycollection.Add(); } GUI.color = Color.red; if (GUILayout.Button("Clear Sounds")) { if (EditorUtility.DisplayDialog("Clear All Sounds", "Are sure you want to clear all the sounds? This action cannot be undone.", "Yes Damnit (╯°□°)╯︵ ┻━┻", "Oh god no")) { mycollection.sounds.Clear(); } } GUI.color = Color.white; EditorGUILayout.Space(); EditorGUILayout.Space(); GUIContent content = new GUIContent("Sound Type ", HELP_MESSAGE_SOUND_TYPE); mycollection.soundType = (SoundType)EditorGUILayout.EnumPopup(mycollection.soundType); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); foreach (Sound sound in mycollection.sounds) { EditorGUILayout.BeginVertical("Box"); sound.show = EditorGUILayout.Foldout(sound.show, sound.name); if (sound.show) { EditorGUILayout.Space(); content = new GUIContent("Name ", HELP_MESSAGE_NAME); sound.name = EditorGUILayout.TextField(content, sound.name); EditorGUILayout.Space(); content = new GUIContent("Audio Clip ", HELP_MESSAGE_AUDIO_CLIP); sound.audioClip = (AudioClip)EditorGUILayout.ObjectField(content, sound.audioClip, typeof(AudioClip), true); EditorGUILayout.Space(); content = new GUIContent("Volume ", HELP_MESSAGE_VOLUME); sound.volume = EditorGUILayout.Slider(content, sound.volume, 0f, 1f); EditorGUILayout.Space(); content = new GUIContent("Instance Limit ", HELP_MESSAGE_INSTANCE_LIMIT); sound.instanceLimit = EditorGUILayout.IntField(content, sound.instanceLimit); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); content = new GUIContent("Pitch ", HELP_MESSAGE_PITCH); EditorGUILayout.LabelField(content); float minVal = sound.minPitch; float maxVal = sound.maxPitch; EditorGUILayout.MinMaxSlider(ref minVal, ref maxVal, 0f, 3f); sound.minPitch = minVal; sound.maxPitch = maxVal; EditorGUILayout.BeginHorizontal(); float width = EditorGUIUtility.currentViewWidth - 50; EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("min", GUILayout.Width(width / 2)); sound.minPitch = EditorGUILayout.FloatField(sound.minPitch, GUILayout.Width(width / 2)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("max", GUILayout.Width(width / 2)); sound.maxPitch = EditorGUILayout.FloatField(sound.maxPitch, GUILayout.Width(width / 2)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); content = new GUIContent("Spatial Blend ", HELP_MESSAGE_SPATIAL_BLEND); sound.spatialBlend = EditorGUILayout.Slider(content, sound.spatialBlend, 0f, 1f); EditorGUILayout.Space(); content = new GUIContent("Loop ", HELP_MESSAGE_LOOP); sound.loop = EditorGUILayout.Toggle(content, sound.loop); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Reset")) { mycollection.Reset(sound); break; } if (GUILayout.Button("Remove")) { mycollection.Remove(sound); break; } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } }