private void CreateEventPrefab(int levelSize) { GameObject go = new GameObject(); Manager.EventTree = AudioEventWorker.CreateTree(go, levelSize); SaveAndLoad.CreateAudioEventRootPrefab(go); }
private static void NewEventArea(InAudioEventNode 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 action")) { ShowCreationContext(audioevent); } var dragging = DragAndDrop.objectReferences; OnDragging.OnDraggingObject(dragging, lastArea, objects => AudioEventWorker.CanDropObjects(audioevent, dragging), objects => AudioEventWorker.OnDrop(audioevent, dragging)); GUI.skin.label.alignment = defaultAlignment; }
public static void StartFromScratch(InCommonDataManager Manager) { SystemFolderHelper.CreateIfMissing(FolderSettings.BankCreateFolder); try { DataCleanup.Cleanup(DataCleanup.CleanupVerbose.Silent); } catch (Exception) { //Do nothing as something is seriously wrong } int levelSize = 3; GameObject audioGO = new GameObject(); GameObject eventGO = new GameObject(); GameObject busGO = new GameObject(); GameObject bankGO = new GameObject(); Manager.BusTree = AudioBusWorker.CreateTree(busGO); Manager.BankLinkTree = AudioBankWorker.CreateTree(bankGO); Manager.AudioTree = AudioNodeWorker.CreateTree(audioGO, levelSize, Manager.BusTree); Manager.EventTree = AudioEventWorker.CreateTree(eventGO, levelSize); SaveAndLoad.CreateDataPrefabs(Manager.AudioTree.gameObject, Manager.EventTree.gameObject, Manager.BusTree.gameObject, Manager.BankLinkTree.gameObject); Manager.Load(true); if (Manager.BankLinkTree != null) { var bankLink = Manager.BankLinkTree.Children[0]; bankLink.Name = "Default - Auto loaded"; bankLink.AutoLoad = true; NodeWorker.AssignToNodes(Manager.AudioTree, node => { var data = (node.NodeData as InFolderData); if (data != null) { data.BankLink = Manager.BankLinkTree.GetChildren[0]; } }); NodeWorker.AssignToNodes(Manager.AudioTree, node => node.Bus = Manager.BusTree); AssetDatabase.Refresh(); DataCleanup.Cleanup(DataCleanup.CleanupVerbose.Silent); EditorApplication.SaveCurrentSceneIfUserWantsTo(); } else { Debug.LogError("There was a problem creating the data."); } }
private void CreateChild(InAudioEventNode node, EventNodeType type) { InUndoHelper.DoInGroup(() => { InUndoHelper.RegisterUndo(node, "Event Creation"); AudioEventWorker.CreateNode(node, type); }); node.EditorSettings.IsFoldedOut = true; }
private void CreateFolderInNewPrefab(InAudioEventNode parent) { InAudioWindowOpener.ShowNewDataWindow((gameObject => { InUndoHelper.DoInGroup(() => { var node = AudioEventWorker.CreateNode(parent, gameObject, EventNodeType.Folder); node.Name += " (External)"; node.PlacedExternaly = true; }); })); isDirty = true; }
private static void ShowCreationContext(InAudioEventNode audioevent) { var menu = new GenericMenu(); List <EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList(); foreach (EventActionExtension.ActionMeta currentType in actionList) { Type newType = AudioEventAction.ActionEnumToType(currentType.ActionType); var enumType = currentType.ActionType; menu.AddItem(new GUIContent(currentType.Name), false, f => AudioEventWorker.AddEventAction(audioevent, newType, enumType), currentType); } menu.ShowAsContext(); }
private static void ChangeAction(InAudioEventNode audioEvent, AudioEventAction action, EventActionTypes newEnumType) { for (int i = 0; i < audioEvent._actionList.Count; ++i) { if (audioEvent._actionList[i] == action) { Type oldType = AudioEventAction.ActionEnumToType(action._eventActionType); Type newType = AudioEventAction.ActionEnumToType(newEnumType); if (oldType != newType) { InUndoHelper.DoInGroup(() => AudioEventWorker.ReplaceActionDestructiveAt(audioEvent, newEnumType, i)); } else { InUndoHelper.RecordObject(action, "Change Event Action Type"); action._eventActionType = newEnumType; } break; } } }
public void ReceiveNode(InMusicGroup group) { if (SelectedNode != null) { InUndoHelper.DoInGroup(() => { TreeWalker.ForEachParent(SelectedNode, n => n.EditorSettings.IsFoldedOut = true); InUndoHelper.RecordObject(SelectedNode, "Send to Event"); if (SelectedNode.IsRootOrFolder) { var myEvent = AudioEventWorker.CreateNode(SelectedNode, EventNodeType.Event); var myAction = AudioEventWorker.AddEventAction <InEventMusicControl>(myEvent, EventActionTypes.PlayMusic); myAction.Target = group; SelectedNode = myEvent; treeDrawer.SelectedNode = myEvent; } else { var myAction = AudioEventWorker.AddEventAction <InEventMusicControl>(SelectedNode, EventActionTypes.PlayMusic); myAction.Target = group; } }); } }
public void ReceiveNode(InAudioNode node) { if (SelectedNode != null) { InUndoHelper.DoInGroup(() => { TreeWalker.ForEachParent(SelectedNode, n => n.FoldedOut = true); InUndoHelper.RecordObject(SelectedNode, "Send to Event"); if (SelectedNode.IsRootOrFolder) { var myEvent = AudioEventWorker.CreateNode(SelectedNode, EventNodeType.Event); var myAction = AudioEventWorker.AddEventAction <InEventAudioAction>(myEvent, EventActionTypes.Play); myAction.Target = node; SelectedNode = myEvent; treeDrawer.SelectedNode = myEvent; } else { var myAction = AudioEventWorker.AddEventAction <InEventAudioAction>(SelectedNode, EventActionTypes.Play); myAction.Target = node; } }); } }
public static void StartFromScratch(InCommonDataManager Manager) { try { DataCleanup.Cleanup(DataCleanup.CleanupVerbose.Silent); } catch (Exception) { Debug.LogError("InAudio: Problem cleaning data before creating project.\nPlease report bug to [email protected] or via the feedback window."); } CreateAll(Manager); Manager.ForceLoad(); try { var firstAudioFolder = Manager.AudioTree._children[0]; AudioNodeWorker.CreateChild(firstAudioFolder, AudioNodeType.Audio, "Empty Example Audio Node"); var random = AudioNodeWorker.CreateChild(firstAudioFolder, AudioNodeType.Random); random.Name = "Random Node Example"; AudioNodeWorker.CreateChild(random, AudioNodeType.Audio, "Empty Example Audio Node"); AudioNodeWorker.CreateChild(random, AudioNodeType.Audio, "Empty Example Audio Node"); AudioNodeWorker.CreateChild(random, AudioNodeType.Audio, "Empty Example Audio Node"); var multi = AudioNodeWorker.CreateChild(firstAudioFolder, AudioNodeType.Multi, "Multi-Sound Example"); AudioNodeWorker.CreateChild(multi, AudioNodeType.Audio, "Played simultaneously"); AudioNodeWorker.CreateChild(multi, AudioNodeType.Audio, "Played simultaneously"); var sequence = AudioNodeWorker.CreateChild(firstAudioFolder, AudioNodeType.Sequence, "Sequence-Sound Example"); AudioNodeWorker.CreateChild(sequence, AudioNodeType.Audio, "Played first"); AudioNodeWorker.CreateChild(sequence, AudioNodeType.Audio, "Played secondly"); var firstMusicFolder = Manager.MusicTree._children[0]; var musicGroup = MusicWorker.CreateMusicGroup(firstMusicFolder, "Example Music Group"); firstMusicFolder.EditorSettings.IsFoldedOut = true; MusicWorker.CreateMusicGroup(musicGroup, "Example Music Group - Layer 1"); MusicWorker.CreateMusicGroup(musicGroup, "Example Music Group - Layer 2"); musicGroup.EditorSettings.IsFoldedOut = true; var firstEventFolder = Manager.EventTree._children[0]; firstEventFolder.EditorSettings.IsFoldedOut = true; var audioEvent = AudioEventWorker.CreateNode(firstEventFolder, EventNodeType.Event); audioEvent.Name = "Playing Music & Random Audio Event"; var musicAction = AudioEventWorker.AddEventAction <InEventMusicControl>(audioEvent, EventActionTypes.PlayMusic); audioEvent.EditorSettings.IsFoldedOut = true; musicAction.MusicGroup = musicGroup; var action = AudioEventWorker.AddEventAction <InEventAudioAction>(audioEvent, EventActionTypes.Play); audioEvent.EditorSettings.IsFoldedOut = true; action.Node = random; AssetDatabase.Refresh(); DataCleanup.Cleanup(DataCleanup.CleanupVerbose.Silent); #if !UNITY_5_2 EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); #else EditorApplication.MarkSceneDirty(); EditorApplication.SaveCurrentSceneIfUserWantsTo(); #endif } catch (Exception) { Debug.LogError("InAudio: There was a problem creating the data.\nPlease report this bug to [email protected] or via the feedback window."); } }
public static bool Draw(InAudioEventNode audioevent) { if (ListAdapter == null) { ListAdapter = new EventActionListAdapter(); ListAdapter.DrawEvent = DrawItem; ListAdapter.ClickedInArea = ClickedInArea; } if (lastEvent != audioevent) { ListAdapter.Event = audioevent; audioEventAction = null; if (audioevent._actionList.Count > 0) { audioEventAction = audioevent._actionList[0]; } } EditorGUILayout.BeginVertical(); lastEvent = audioevent; InUndoHelper.GUIUndo(audioevent, "Name Change", ref audioevent.Name, () => EditorGUILayout.TextField("Name", audioevent.Name)); bool repaint = false; if (audioevent._type == EventNodeType.Event) { EditorGUIHelper.DrawID(audioevent._guid); if (Application.isPlaying) { eventObjectTarget = EditorGUILayout.ObjectField("Event preview target", eventObjectTarget, typeof(GameObject), true) as GameObject; if (eventObjectTarget != null) { bool prefab = PrefabUtility.GetPrefabParent(eventObjectTarget) == null && PrefabUtility.GetPrefabObject(eventObjectTarget) != null; if (!prefab) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Post event")) { InAudio.PostEvent(eventObjectTarget, audioevent); } if (GUILayout.Button("Stop All Sounds/Music in Event")) { InAudio.StopAll(eventObjectTarget); foreach (var eventAction in audioevent._actionList) { var music = eventAction.Target as InMusicGroup; if (music != null) { InAudio.Music.Stop(music); } } } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("Cannot post events on Prefab", MessageType.Error); } } EditorGUILayout.Separator(); } InUndoHelper.GUIUndo(audioevent, "Delay", ref audioevent.Delay, () => Mathf.Max(EditorGUILayout.FloatField("Delay", audioevent.Delay), 0)); NewEventArea(audioevent); EditorGUILayout.Separator(); EditorGUILayout.Separator(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); repaint = DrawContent(); EditorGUILayout.EndScrollView(); DrawSelected(audioEventAction); } else if (audioevent._type == EventNodeType.Folder) { if (audioevent.PlacedExternaly) { EditorGUILayout.Separator(); GUI.enabled = false; EditorGUILayout.ObjectField("Placed on", audioevent.gameObject, typeof(GameObject), false); GUI.enabled = true; EditorGUILayout.Separator(); } } EditorGUILayout.EndVertical(); if (toRemove != null) { InUndoHelper.DoInGroup(() => { //Remove the required piece int index = audioevent._actionList.FindIndex(toRemove); AudioEventWorker.DeleteActionAtIndex(audioevent, index); }); toRemove = null; } else //Remove all actions that does not excist. { audioevent._actionList.RemoveAll(p => p == null); } return(repaint); }
public static void StartFromScratch(InCommonDataManager Manager) { try { DataCleanup.Cleanup(DataCleanup.CleanupVerbose.Silent); } catch (Exception) { Debug.LogError("InAudio: Problem cleaning data before creating project.\nPlease report bug to [email protected] or via the feedback window."); } int levelSize = 3; GameObject audioGO = new GameObject(); GameObject eventGO = new GameObject(); GameObject bankGO = new GameObject(); GameObject musicGO = new GameObject(); Manager.BankLinkTree = AudioBankWorker.CreateTree(bankGO); Manager.AudioTree = AudioNodeWorker.CreateTree(audioGO, levelSize); Manager.MusicTree = MusicWorker.CreateTree(musicGO, levelSize); Manager.EventTree = AudioEventWorker.CreateTree(eventGO, levelSize); SaveAndLoad.CreateDataPrefabs(Manager.AudioTree.gameObject, Manager.MusicTree.gameObject, Manager.EventTree.gameObject, Manager.BankLinkTree.gameObject); Manager.Load(true); if (Manager.BankLinkTree != null) { var bankLink = Manager.BankLinkTree._children[0]; bankLink._name = "Default - Auto loaded"; bankLink._autoLoad = true; NodeWorker.AssignToNodes(Manager.AudioTree, node => { var data = (node._nodeData as InFolderData); if (data != null) { data.BankLink = Manager.BankLinkTree._getChildren[0]; } }); NodeWorker.AssignToNodes(Manager.MusicTree, musicNode => { var folder = musicNode as InMusicFolder; if (folder != null) { folder._bankLink = Manager.BankLinkTree._getChildren[0]; } }); var firstAudioFolder = Manager.AudioTree._children[0]; AudioNodeWorker.CreateChild(firstAudioFolder, AudioNodeType.Audio, "Empty Example Audio Node"); var random = AudioNodeWorker.CreateChild(firstAudioFolder, AudioNodeType.Random); random.Name = "Random Node Example"; AudioNodeWorker.CreateChild(random, AudioNodeType.Audio, "Empty Example Audio Node"); AudioNodeWorker.CreateChild(random, AudioNodeType.Audio, "Empty Example Audio Node"); AudioNodeWorker.CreateChild(random, AudioNodeType.Audio, "Empty Example Audio Node"); var multi = AudioNodeWorker.CreateChild(firstAudioFolder, AudioNodeType.Multi, "Multi-Sound Example"); AudioNodeWorker.CreateChild(multi, AudioNodeType.Audio, "Played simultaneously"); AudioNodeWorker.CreateChild(multi, AudioNodeType.Audio, "Played simultaneously"); var sequence = AudioNodeWorker.CreateChild(firstAudioFolder, AudioNodeType.Sequence, "Sequence-Sound Example"); AudioNodeWorker.CreateChild(sequence, AudioNodeType.Audio, "Played first"); AudioNodeWorker.CreateChild(sequence, AudioNodeType.Audio, "Played secondly"); var firstEventFolder = Manager.EventTree._children[0]; firstEventFolder.FoldedOut = true; var audioEvent = AudioEventWorker.CreateNode(firstEventFolder, EventNodeType.Event); audioEvent.Name = "Playing Random Audio Event"; var action = AudioEventWorker.AddEventAction <InEventAudioAction>(audioEvent, EventActionTypes.Play); audioEvent.FoldedOut = true; action.Node = random; var firstMusicFolder = Manager.MusicTree._children[0]; var musicGroup = MusicWorker.CreateMusicGroup(firstMusicFolder, "Empty Music Group"); firstMusicFolder.FoldedOut = true; MusicWorker.CreateMusicGroup(musicGroup, "Empty Music Group - Child 1"); MusicWorker.CreateMusicGroup(musicGroup, "Empty Music Group - Child 2"); musicGroup.FoldedOut = true; AssetDatabase.Refresh(); DataCleanup.Cleanup(DataCleanup.CleanupVerbose.Silent); #if !UNITY_5_2 EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); #else EditorApplication.MarkSceneDirty(); EditorApplication.SaveCurrentSceneIfUserWantsTo(); #endif } else { Debug.LogError("InAudio: There was a problem creating the data.\nPlease report this bug to [email protected] or via the feedback window."); } }
protected override void OnContext(InAudioEventNode node) { var menu = new GenericMenu(); #region Duplicate if (!node.IsRoot) { menu.AddItem(new GUIContent("Duplicate"), false, data => AudioEventWorker.Duplicate(data as InAudioEventNode), node); } else { menu.AddDisabledItem(new GUIContent("Duplicate")); } menu.AddSeparator(""); #endregion #region Duplicate if (node.IsRootOrFolder) { menu.AddItem(new GUIContent("Create child folder in new prefab"), false, obj => { CreateFolderInNewPrefab(node); }, node); menu.AddSeparator(""); } #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(); }
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; }