public static void DrawBus(InAudioNode node) { if (!node.IsRoot) { bool overrideParent = EditorGUILayout.Toggle("Override Parent Bus", node.OverrideParentBus); if (overrideParent != node.OverrideParentBus) { UndoHelper.RecordObjectFull(new Object[] { node.NodeData, node }, "Override parent bus"); node.OverrideParentBus = overrideParent; } if (!node.OverrideParentBus) { GUI.enabled = false; } } EditorGUILayout.BeginHorizontal(); // if (node.GetBus() != null) { var usedBus = node.GetBus(); if (usedBus != null) { EditorGUILayout.TextField("Used Bus", usedBus.Name); } else { EditorGUILayout.TextField("Used Bus", "Missing bus"); } } else { GUILayout.Label("Missing node"); } if (GUILayout.Button("Find")) { SearchHelper.SearchFor(node.Bus); } GUI.enabled = true; GUILayout.Button("Drag bus here to assign"); var buttonArea = GUILayoutUtility.GetLastRect(); var bus = HandleBusDrag(buttonArea); if (bus != null) { UndoHelper.RecordObjectFull(node, "Assign bus"); node.Bus = bus; node.OverrideParentBus = true; Event.current.Use(); } EditorGUILayout.EndHorizontal(); }
private void CreateChildBus(object userData) { InAudioBus bus = userData as InAudioBus; UndoHelper.DoInGroup(() => { UndoHelper.RecordObjectFull(bus, "Bus Creation"); AudioBusWorker.CreateChild(bus); }); }
private void CreateChild(InAudioNode parent, AudioNodeType type) { UndoHelper.RecordObjectFull(new UnityEngine.Object[] { parent, parent.GetBank().LazyBankFetch }, "Create Audio Node"); var newNode = AudioNodeWorker.CreateChild(parent, type); if (type == AudioNodeType.Audio) { AudioBankWorker.AddNodeToBank(newNode, null); } }
private void CreateBank(InAudioBankLink parent, AudioBankTypes type) { //TODO make real undo UndoHelper.RecordObjectFull(parent, "Bank " + (type == AudioBankTypes.Folder ? "Folder " : "") + "Creation"); if (type == AudioBankTypes.Folder) { AudioBankWorker.CreateFolder(parent.gameObject, parent, GUIDCreator.Create()); } else { AudioBankWorker.CreateBank(parent.gameObject, parent, GUIDCreator.Create()); } }
//private static InAudioNode activeNode; public static void Draw(InAudioNode node) { EditorGUILayout.BeginVertical(); var trackData = (node.NodeData as InTrackData); NodeTypeDataDrawer.DrawName(node); UndoHelper.GUIUndo(trackData, "Track length", ref trackData.TrackLength, () => EditorGUILayout.FloatField("Track length", trackData.TrackLength)); UndoHelper.GUIUndo(trackData, "Zoom", ref trackData.Zoom, () => EditorGUILayout.FloatField("Zoom", trackData.Zoom)); selectedArea = GUILayout.SelectionGrid(selectedArea, new [] { "Track", "Normal" }, 2); if (selectedArea == 1) { NodeTypeDataDrawer.Draw(node); } else { EditorGUILayout.BeginVertical(); ScrollArea = EditorGUILayout.BeginScrollView(ScrollArea, false, true); foreach (var layer in trackData.Layers) { DrawItem(node, layer); } if (GUILayout.Button("Add Layer", GUILayout.Width(150))) { UndoHelper.RecordObjectFull(trackData, "Add layer"); trackData.Layers.Add(new InLayerData()); } if (GUILayout.Button("Delete Last Layer", GUILayout.Width(150))) { UndoHelper.RecordObjectFull(trackData, "Remove layer"); { if (trackData.Layers.Count > 0) { trackData.Layers.RemoveAt(trackData.Layers.Count - 1); } } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); }
public static void Draw(InAudioBankLink bankLink) { EditorGUILayout.BeginVertical(); UndoHelper.GUIUndo(bankLink, "Name Change", ref bankLink.Name, () => EditorGUILayout.TextField("Name", bankLink.Name)); if (bankLink.Type == AudioBankTypes.Link) { EditorGUIHelper.DrawID(bankLink.GUID); bool autoLoad = EditorGUILayout.Toggle("Auto load", bankLink.AutoLoad); if (autoLoad != bankLink.AutoLoad) //Value has changed { UndoHelper.RecordObjectFull(bankLink, "Bank Auto Load"); bankLink.AutoLoad = autoLoad; } Rect lastArea = GUILayoutUtility.GetLastRect(); lastArea.y += 28; lastArea.width = 200; if (GUI.Button(lastArea, "Find Folders using this bank")) { EditorWindow.GetWindow <InAudioWindow>().Find(audioNode => audioNode.GetBank() != bankLink); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (Application.isPlaying) { EditorGUILayout.Toggle("Is Loaded", bankLink.IsLoaded); } } EditorGUILayout.EndVertical(); //UndoCheck.Instance.CheckDirty(node); }
public static void Draw(InAudioNode node) { UndoHelper.GUIUndo(node, "Name Change", ref node.Name, () => EditorGUILayout.TextField("Name", node.Name)); Rect area = GUILayoutUtility.GetLastRect(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); InAudioData audioData = node.NodeData as InAudioData; EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(""); area = GUILayoutUtility.GetLastRect(); Rect objectArea = area; if (Application.isPlaying) { objectArea.width -= 100; } var clip = (AudioClip)EditorGUI.ObjectField(objectArea, audioData.EditorClip, typeof(AudioClip), false); Rect buttonArea = area; if (Application.isPlaying) { buttonArea.x += buttonArea.width - 100; buttonArea.width = 70; GUI.enabled = false; EditorGUI.LabelField(buttonArea, "Is Loaded"); buttonArea.x += 70; buttonArea.width = 10; EditorGUI.Toggle(buttonArea, audioData.RuntimeClip != null); GUI.enabled = true; } if (GUILayout.Button("Preview", GUILayout.Width(60))) { AudioSource source = InAudioInstanceFinder.Instance.GetComponent <AudioSource>(); var root = TreeWalker.FindParentBeforeFolder(node); source.volume = RuntimeHelper.ApplyVolume(root, node); source.pitch = RuntimeHelper.ApplyPitch(root, node); source.clip = audioData.EditorClip; source.Play(); } if (GUILayout.Button("Raw", GUILayout.Width(45))) { AudioSource source = InAudioInstanceFinder.Instance.GetComponent <AudioSource>(); source.clip = audioData.EditorClip; source.volume = 1.0f; source.pitch = 1.0f; source.Play(); } if (GUILayout.Button("Stop", GUILayout.Width(45))) { AudioSource source = InAudioInstanceFinder.Instance.GetComponent <AudioSource>(); source.Stop(); source.clip = null; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (audioData.RuntimeClip != null && Application.isPlaying) { audioData.RuntimeClip = clip; } if (clip != audioData.EditorClip) //Assign new clip { UndoHelper.RecordObjectFull(new Object[] { audioData, node.GetBank().LazyBankFetch }, "Changed " + node.Name + " Clip"); audioData.EditorClip = clip; audioData.RuntimeClip = clip; AudioBankWorker.SwapClipInBank(node, clip); EditorUtility.SetDirty(node.GetBank().LazyBankFetch.gameObject); EditorUtility.SetDirty(node.NodeData.gameObject); } EditorGUILayout.EndHorizontal(); NodeTypeDataDrawer.Draw(node); }
public static void Draw(InAudioBus bus) { EditorGUILayout.BeginVertical(); UndoHelper.GUIUndo(bus, "Name Change", ref bus.Name, () => EditorGUILayout.TextField("Name", bus.Name)); EditorGUIHelper.DrawID(bus.GUID); EditorGUILayout.Separator(); if (!Application.isPlaying) { UndoHelper.GUIUndo(bus, "Mute Bus", ref bus.Mute, () => EditorGUILayout.Toggle("Initial Mute", bus.Mute)); } else { UndoHelper.GUIUndo(bus, "Mute Bus (Runtime)", ref bus.RuntimeMute, () => EditorGUILayout.Toggle("Mute (Runtime)", bus.RuntimeMute)); } EditorGUILayout.Separator(); UndoHelper.GUIUndo(bus, "Volume Change", ref bus.Volume, () => EditorGUILayout.Slider("Master Volume", bus.Volume, 0.0f, 1.0f)); if (!Application.isPlaying) { UndoHelper.GUIUndo(bus, "Runtime Volume Change", ref bus.SelfVolume, () => EditorGUILayout.Slider("Initial Runtime Volume", bus.SelfVolume, 0.0f, 1.0f)); } else { UndoHelper.GUIUndo(bus, "Runtime Volume Change", ref bus.RuntimeSelfVolume, () => EditorGUILayout.Slider("Runtime Volume", bus.RuntimeSelfVolume, 0.0f, 1.0f)); } EditorGUILayout.Separator(); GUI.enabled = false; if (Application.isPlaying) { EditorGUILayout.Slider("Ducking", bus.LastDuckedVolume, -1.0f, 0.0f); EditorGUILayout.Separator(); EditorGUILayout.Slider("Final Hierarchy Volume", Mathf.Clamp(bus.FinalVolume, 0, 1), 0, 1.0f); } else { float volume = bus.CombinedVolume; if (bus.RuntimeMute) { volume = 0; } EditorGUILayout.Slider("Final Hierarchy Volume", volume, 0, 1.0f); } GUI.enabled = true; EditorGUILayout.Separator(); EditorGUILayout.Separator(); //Not implemented yet #region Ducking EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Hold Control down and drag a bus here."); EditorGUILayout.LabelField("Cannot add parents or children."); GUILayout.Button("Drag bus here", GUILayout.Width(200)); var dragging = DragAndDrop.objectReferences; OnDragging.OnDraggingObject <InAudioBus>(dragging, GUILayoutUtility.GetLastRect(), buses => AudioBusWorker.CanBeDuckedBy(bus, buses[0]), buses => { UndoHelper.RecordObject(bus, "Add"); for (int i = 0; i < buses.Length; i++) { DuckingData data = new DuckingData(); data.DuckedBy = buses[i]; bus.DuckedBy.Add(data); } } ); EditorGUILayout.LabelField(""); Rect labelArea = GUILayoutUtility.GetLastRect(); labelArea.width = labelArea.width / 4.0f - 5; Rect workArea = labelArea; for (int i = 0; i < bus.DuckedBy.Count; i++) { workArea.width = labelArea.width; workArea.y += workArea.height + 4; workArea.x = labelArea.x; DuckingData data = bus.DuckedBy[i]; EditorGUI.SelectableLabel(workArea, data.DuckedBy.Name); Rect area1 = workArea; workArea.x += workArea.width; UndoHelper.GUIUndo(bus, "Duck Amount Change", () => EditorGUI.Slider(workArea, data.VolumeDucking, -1.0f, 0.0f), v => data.VolumeDucking = v); Rect area2 = workArea; workArea.x += workArea.width; UndoHelper.GUIUndo(bus, "Attack Time", () => EditorGUI.Slider(workArea, data.AttackTime, 0.0f, 10.0f), v => data.AttackTime = v); Rect area3 = workArea; workArea.x += workArea.width; UndoHelper.GUIUndo(bus, "Release Time", () => EditorGUI.Slider(workArea, data.ReleaseTime, 0.0f, 10.0f), v => data.ReleaseTime = v); Rect area4 = workArea; workArea.x += workArea.width; workArea.width = 20; if (GUI.Button(workArea, "X")) { UndoHelper.RecordObjectFull(bus, "X"); bus.DuckedBy.RemoveAt(i); i--; } if (i == 0) //Workaround to avoid a gui layout mismatch { area1.y -= 20; area2.y -= 20; area3.y -= 20; area4.y -= 20; EditorGUI.LabelField(area1, "Ducked By"); EditorGUI.LabelField(area2, "Volume Duck Amount"); EditorGUI.LabelField(area3, "Attack Time"); EditorGUI.LabelField(area4, "Release Time"); } } #endregion /* GUILayout.Label("Nodes Playing In This Specific Bus"); * * lastArea.x += 20; * lastArea.y = lastArea.y + lastArea.height + 2; * lastArea.height = 17; * List<RuntimePlayer> players = node.GetRuntimePlayers(); * for (int i = 0; i < players.Count; i++) * { * GUI.Label(lastArea, players[i].NodePlaying.Name); * * lastArea.y += 20; * } */ EditorGUILayout.EndVertical(); }