private static void NewEventArea(AudioEvent audioevent) { var defaultAlignment = GUI.skin.label.alignment; EditorGUILayout.BeginHorizontal(); GUI.skin.label.alignment = TextAnchor.MiddleLeft; EditorGUILayout.LabelField(""); EditorGUILayout.EndHorizontal(); Rect lastArea = GUILayoutUtility.GetLastRect(); lastArea.height *= 1.5f; if (GUI.Button(lastArea, "Click or drag here to add event")) { ShowCreationContext(audioevent); } if (Event.current.type != EventType.Repaint) { var dragging = DragAndDrop.objectReferences; OnDragging.OnDraggingObject(dragging, lastArea, objects => AudioEventWorker.CanDropObjects(audioevent, dragging), objects => AudioEventWorker.OnDrop(audioevent, dragging)); } GUI.skin.label.alignment = defaultAlignment; }
private void CreateEventPrefab(int levelSize) { GameObject go = new GameObject(); Manager.EventTree = AudioEventWorker.CreateTree(go, levelSize); SaveAndLoad.CreateAudioEventRootPrefab(go); }
private void CreateChild(InAudioEventNode node, EventNodeType type) { UndoHelper.DoInGroup(() => { UndoHelper.RegisterUndo(node, "Event Creation"); AudioEventWorker.CreateNode(node, type); }); node.FoldedOut = true; }
private void DrawStartFromScratch() { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Start over from scratch", GUILayout.Height(30))) { if (EditorUtility.DisplayDialog("Create new project?", "This will delete ALL data!", "Start from scratch", "Do nothing")) { FolderSettings.DeleteFolderContent(Application.dataPath + FolderSettings.BankDeleteFolder); int levelSize = 3; GameObject go1 = new GameObject(); GameObject go2 = new GameObject(); GameObject go3 = new GameObject(); GameObject go4 = new GameObject(); Manager.BusTree = AudioBusWorker.CreateTree(go3); Manager.BankLinkTree = AudioBankWorker.CreateTree(go4); Manager.AudioTree = AudioNodeWorker.CreateTree(go1, levelSize, Manager.BusTree); Manager.EventTree = AudioEventWorker.CreateTree(go2, levelSize); SaveAndLoad.CreateDataPrefabs(Manager.AudioTree.gameObject, Manager.EventTree.gameObject, Manager.BusTree.gameObject, Manager.BankLinkTree.gameObject); Manager.Load(true); if (Manager.BankLinkTree != null) { var bankLink = AudioBankWorker.CreateBank(Manager.BankLinkTree.gameObject, Manager.BankLinkTree, GUIDCreator.Create()); bankLink.Name = "Default - Auto loaded"; bankLink.AutoLoad = true; var bankLink2 = AudioBankWorker.CreateBank(Manager.BankLinkTree.gameObject, Manager.BankLinkTree, GUIDCreator.Create()); bankLink2.Name = "Extra"; NodeWorker.AssignToNodes(Manager.AudioTree, node => node.BankLink = Manager.BankLinkTree.GetChildren[0]); } else { Debug.LogError("There was a problem creating the data."); } NodeWorker.AssignToNodes(Manager.AudioTree, node => node.Bus = Manager.BusTree); AssetDatabase.Refresh(); EditorApplication.SaveCurrentSceneIfUserWantsTo(); } } }
protected override void OnContext(AudioEvent node) { var menu = new GenericMenu(); #region Duplicate if (!node.IsRoot) { menu.AddItem(new GUIContent("Duplicate"), false, data => AudioEventWorker.Duplicate(data as AudioEvent), node); } else { menu.AddDisabledItem(new GUIContent("Duplicate")); } #endregion menu.AddSeparator(""); #region Create child if (node.Type == EventNodeType.Root) { menu.AddItem(new GUIContent(@"Create Child/Folder"), false, data => { CreateChild(node, EventNodeType.Folder); }, node); menu.AddItem(new GUIContent(@"Create Child/Event Group"), false, data => { CreateChild(node, EventNodeType.EventGroup); }, node); menu.AddDisabledItem(new GUIContent(@"Create Child/Event")); } if (node.Type == EventNodeType.Folder) { menu.AddItem(new GUIContent(@"Create Child/Folder"), false, data => { CreateChild(node, EventNodeType.Folder); }, node); menu.AddItem(new GUIContent(@"Create Child/Event Group"), false, data => { CreateChild(node, EventNodeType.EventGroup); }, node); menu.AddItem(new GUIContent(@"Create Child/Event"), false, data => { CreateChild(node, EventNodeType.Event); }, node); } if (node.Type == EventNodeType.EventGroup) { menu.AddDisabledItem(new GUIContent(@"Create Child/Folder")); menu.AddDisabledItem(new GUIContent(@"Create Child/Event Group")); menu.AddItem(new GUIContent(@"Create Child/Event"), false, data => { CreateChild(node, EventNodeType.Event); }, node); } if (node.Type == EventNodeType.Event) { menu.AddDisabledItem(new GUIContent(@"Create Child/Folder")); menu.AddDisabledItem(new GUIContent(@"Create Child/Event Group")); menu.AddDisabledItem(new GUIContent(@"Create Child/Event")); } #endregion menu.AddSeparator(""); menu.AddItem(new GUIContent(@"Delete"), false, data => AudioEventWorker.DeleteNode(node), node); menu.ShowAsContext(); }
private static void ShowCreationContext(AudioEvent audioevent) { var menu = new GenericMenu(); foreach (EventActionTypes currentType in EnumUtil.GetValues <EventActionTypes>()) { Type newType = AudioEventWorker.ActionEnumToType(currentType); var enumType = currentType; menu.AddItem(new GUIContent(currentType.FormatedName()), false, f => AudioEventWorker.AddEventAction(audioevent, newType, enumType), currentType); } menu.ShowAsContext(); }
protected override void OnContext(InAudioEventNode node) { var menu = new GenericMenu(); #region Duplicate #if !UNITY_4_1 && !UNITY_4_2 if (!node.IsRoot) { menu.AddItem(new GUIContent("Duplicate"), false, data => AudioEventWorker.Duplicate(data as InAudioEventNode), node); } else { menu.AddDisabledItem(new GUIContent("Duplicate")); } menu.AddSeparator(""); #endif #endregion #region Create child if (node.Type == EventNodeType.Root || node.Type == EventNodeType.Folder) { menu.AddItem(new GUIContent(@"Create Event"), false, data => { CreateChild(node, EventNodeType.Event); }, node); menu.AddItem(new GUIContent(@"Create Folder"), false, data => { CreateChild(node, EventNodeType.Folder); }, node); } if (node.Type == EventNodeType.Event) { menu.AddDisabledItem(new GUIContent(@"Create Event")); menu.AddDisabledItem(new GUIContent(@"Create Folder")); } #endregion menu.AddSeparator(""); #region Delete menu.AddItem(new GUIContent(@"Delete"), false, data => { treeDrawer.SelectedNode = TreeWalker.GetPreviousVisibleNode(treeDrawer.SelectedNode); AudioEventWorker.DeleteNode(node); }, node); #endregion menu.ShowAsContext(); }
private static void ChangeAction(AudioEvent audioEvent, AudioEventAction action, EventActionTypes newEnumType) { for (int i = 0; i < audioEvent.ActionList.Count; ++i) { if (audioEvent.ActionList[i] == action) { Type oldType = AudioEventWorker.ActionEnumToType(action.EventActionType); Type newType = AudioEventWorker.ActionEnumToType(newEnumType); if (oldType != newType) { AudioEventWorker.ReplaceActionDestructiveAt(audioEvent, newEnumType, i); } else { action.EventActionType = newEnumType; } break; } } }
protected override bool CanDropObjects(InAudioEventNode audioEvent, Object[] objects) { return(AudioEventWorker.CanDropObjects(audioEvent, objects)); }
protected override void OnDrop(InAudioEventNode audioevent, Object[] objects) { AudioEventWorker.OnDrop(audioevent, objects); treeDrawer.SelectedNode = audioevent; }
private static bool DrawContent(AudioEvent audioevent, Rect area) { Rect selectedBackground = drawArea; selectedBackground.y += 2; DrawBackground(selectedBackground); GUI.skin.label.alignment = TextAnchor.MiddleCenter; bool repaint = false; EditorGUILayout.BeginVertical(); for (int i = 0; i < audioevent.ActionList.Count; ++i) { var currentAction = audioevent.ActionList[i]; Rect lastArea = EditorGUILayout.BeginHorizontal(GUILayout.Height(20)); if (i == 0) { Rect actionArea = lastArea; actionArea.width = 100; actionArea.height = 20; actionArea.y -= 20; EditorGUI.LabelField(actionArea, "Action", EditorStyles.boldLabel); } if (currentAction != null) { if (GUILayout.Button( Enum.GetName(typeof(EventActionTypes), (int)currentAction.EventActionType) .AddSpacesToSentence(), GUILayout.Width(110))) { ShowChangeContext(audioevent, currentAction); Event.current.Use(); } } else { EditorGUILayout.LabelField("Missing"); GUI.enabled = false; } EditorGUILayout.BeginVertical(GUILayout.Height(20)); GUILayout.Label("", GUILayout.Height(0)); //Aligns it to the center by creating a small vertical offset, by setting the height to zero if (currentAction != null && currentAction.EventActionType != EventActionTypes.StopAll) { EditorGUILayout.LabelField(currentAction.ObjectName); } EditorGUILayout.EndHorizontal(); Rect dragArea = GUILayoutUtility.GetLastRect(); if (i == 0) { Rect actionArea = dragArea; actionArea.width = 100; actionArea.height = 20; actionArea.y -= 20; EditorGUI.LabelField(actionArea, "Data", EditorStyles.boldLabel); } if (currentAction is EventAudioAction) { AudioNode dragged = OnDragging.DraggingObject <AudioNode>(dragArea, node => node.IsPlayable); if (dragged != null) { (currentAction as EventAudioAction).Node = dragged; } } else if (currentAction is EventBankAction) { AudioBankLink dragged = OnDragging.DraggingObject <AudioBankLink>(dragArea, bank => bank.Type == AudioBankTypes.Link); if (dragged != null) { (currentAction as EventBankAction).BankLink = dragged; } } else if (currentAction is EventBusAction) { AudioBus dragged = OnDragging.DraggingObject <AudioBus>(dragArea, bus => true); if (dragged != null) { (currentAction as EventBusAction).Bus = dragged; } } EditorGUILayout.Separator(); EditorGUILayout.Separator(); Rect rightArea = EditorGUILayout.BeginHorizontal(GUILayout.Width(area.width - 100)); rightArea.x -= 150; rightArea.y += 3; rightArea.width = 80; //rightARea.height -= 6; if (GUI.Button(rightArea, "Find")) { SearchHelper.SearchFor(currentAction); } rightArea.x += 90; rightArea.width = 30; if (GUI.Button(rightArea, "X")) { if (audioevent.ActionList[i] != null) { AudioEventWorker.DeleteActionAtIndex(audioevent, i); } else { audioevent.ActionList.SwapRemoveAt(i); --i; } } if (Event.current.ClickedWithin(lastArea)) { drawArea = lastArea; audioEventAction = currentAction; Event.current.Use(); } //if (audioEventAction == null || ( Event.current.type == EventType.MouseDown && lastArea.Contains(Event.current.mousePosition))) //{ // drawArea = lastArea; // audioEventAction = currentAction; //} GUILayout.Label(""); //EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); GUI.enabled = true; } EditorGUILayout.EndVertical(); return(repaint); }
protected override void OnDrop(AudioEvent audioevent, Object[] objects) { AudioEventWorker.OnDrop(audioevent, objects); }
private void CreateChild(AudioEvent node, EventNodeType type) { AudioEventWorker.CreateNode(node, type); node.FoldedOut = true; }