private void drawAudioProperties() { EditorGUILayout.LabelField("Audio Clips", EditorStyles.boldLabel); EditorGUILayout.BeginVertical(EditorStyles.helpBox); if (interaction.CollisionAudioClips.Count == 0) { EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("No Collision Audio Clips have been added.", GUILayout.Width(250)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); } else { GUILayout.Space(2); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Audio Clip Selection Mode", "Should audio clips be chosen based on Velocity or be chosen Randomly?")); interaction.CollisionAudioSelectionMode = (ImpactAudioInteraction.CollisionAudioClipSelectionMode)EditorGUILayout.EnumPopup(interaction.CollisionAudioSelectionMode); EditorGUILayout.EndHorizontal(); for (int i = 0; i < interaction.CollisionAudioClips.Count; i++) { EditorGUILayout.BeginHorizontal(); if (interaction.CollisionAudioSelectionMode == ImpactAudioInteraction.CollisionAudioClipSelectionMode.Velocity) { EditorGUILayout.LabelField((i + 1) + ")", GUILayout.Width(20)); } else { GUILayout.Space(5); } interaction.CollisionAudioClips[i] = EditorGUILayout.ObjectField(interaction.CollisionAudioClips[i], typeof(AudioClip), false) as AudioClip; Color originalColor = GUI.color; GUI.color = warningColor; if (GUILayout.Button(new GUIContent("X", "Remove"), GUILayout.Width(18), GUILayout.Height(15))) { interaction.CollisionAudioClips.RemoveAt(i); i--; } GUI.color = originalColor; EditorGUILayout.EndHorizontal(); } GUILayout.Space(2); } EditorGUILayout.HelpBox("You can drag-and-drop Audio Clips here to add them.", MessageType.Info); EditorGUILayout.EndVertical(); //Drag and drop Rect listRect = GUILayoutUtility.GetLastRect(); string[] paths; bool drop = ImpactEditorUtilities.DragAndDropArea(listRect, out paths); if (drop && paths != null) { for (int i = 0; i < paths.Length; i++) { AudioClip a = AssetDatabase.LoadAssetAtPath <AudioClip>(paths[i]); if (a != null) { interaction.CollisionAudioClips.Add(a); } } } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Add Collision Audio Clip")) { interaction.CollisionAudioClips.Add(null); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); interaction.SlideAudioClip = EditorGUILayout.ObjectField(new GUIContent("Slide Audio", "The AudioClip to play when sliding."), interaction.SlideAudioClip, typeof(AudioClip), false) as AudioClip; interaction.RollAudioClip = EditorGUILayout.ObjectField(new GUIContent("Roll Audio", "The AudioClip to play when rolling."), interaction.RollAudioClip, typeof(AudioClip), false) as AudioClip; EditorGUILayout.Separator(); interaction.AudioSourceTemplate = EditorGUILayout.ObjectField(new GUIContent("Audio Source Template", "The audio source whose properties will be used when playing sounds from this interaction."), interaction.AudioSourceTemplate, typeof(ImpactAudioSourceBase), false) as ImpactAudioSourceBase; if (interaction.AudioSourceTemplate == null) { EditorGUILayout.HelpBox("You must assign an Audio Source Template for sounds to play for this interaction.", MessageType.Error); } }
private void drawInteractionsList(ImpactMaterialInteractionSet interactionSet) { EditorGUILayout.LabelField("Interactions", EditorStyles.boldLabel); for (int i = 0; i < interactionSet.InteractionCount; i++) { EditorGUILayout.BeginHorizontal(); interactionSet[i] = EditorGUILayout.ObjectField(interactionSet[i], typeof(ImpactInteractionBase), false) as ImpactInteractionBase; Color originalColor = GUI.color; GUI.color = warningColor; if (GUILayout.Button(new GUIContent("X", "Remove"), GUILayout.Width(20), GUILayout.Height(15))) { interactionSet.RemoveInteraction(i); EditorUtility.SetDirty(target); } GUI.color = originalColor; EditorGUILayout.EndHorizontal(); } EditorGUILayout.HelpBox("You can drag-and-drop Interactions here to add them.", MessageType.Info); GUILayout.Space(2); EditorGUILayout.EndVertical(); //Drag and drop Rect listRect = GUILayoutUtility.GetLastRect(); string[] paths; bool drop = ImpactEditorUtilities.DragAndDropArea(listRect, out paths); if (drop && paths != null) { for (int i = 0; i < paths.Length; i++) { ImpactInteractionBase a = AssetDatabase.LoadAssetAtPath <ImpactInteractionBase>(paths[i]); if (a != null) { interactionSet.AddInteraction(a); } } EditorUtility.SetDirty(target); } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Add Interaction")) { interactionSet.AddInteraction(null); EditorUtility.SetDirty(target); } EditorGUILayout.EndHorizontal(); GUILayout.Space(2); EditorGUILayout.EndVertical(); }