Example #1
0
        private void CreateMusicPrefab(int levelSize)
        {
            GameObject go = new GameObject();

            Manager.MusicTree = MusicWorker.CreateTree(go, levelSize);
            SaveAndLoad.CreateMusicRootPrefab(go);
        }
Example #2
0
 private void CreateMusicGroup(InMusicNode parent)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjectFull(parent, "Create Music Folder");
         parent.FoldedOut = true;
         MusicWorker.CreateMusicGroup(parent);
     });
 }
Example #3
0
 private void CreateFolderInNewPrefab(InMusicNode parent)
 {
     InAudioWindowOpener.ShowNewDataWindow((gameObject =>
     {
         var node = MusicWorker.CreateFolder(gameObject, parent);
         node._name += " (External)";
         node._externalPlacement = true;
     }));
 }
Example #4
0
 private void CreateFolder(InMusicNode parent)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjectFull(parent, "Create Music Folder");
         parent.EditorSettings.IsFoldedOut = true;
         MusicWorker.CreateFolder(parent.gameObject, parent);
     });
 }
Example #5
0
        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.");
            }
        }
Example #6
0
        protected override void OnDrop(InMusicNode newParent, UnityEngine.Object[] objects)
        {
            if (newParent == null || objects == null)
            {
                return;
            }

            var dragged = objects[0] as InMusicNode;

            if (dragged != null)
            {
                if (dragged.IsRoot || dragged == newParent)
                {
                    return;
                }

                InUndoHelper.DoInGroup(() =>
                {
                    if (dragged.gameObject != newParent.gameObject)
                    {
                        if (EditorUtility.DisplayDialog("Move?",
                                                        "Warning, this will break all external references to this and all child nodes!\n" +
                                                        "Move node from\"" + dragged.gameObject.name +
                                                        "\" to \"" + newParent.gameObject.name + "\"?", "Ok", "Cancel"))
                        {
                            treeDrawer.SelectedNode = TreeWalker.GetPreviousVisibleNode(treeDrawer.SelectedNode);
                            MusicWorker.Duplicate(newParent.gameObject, dragged, newParent);
                            DeleteNodeRec(dragged);
                            AudioBankWorker.RebuildBanks();
                        }
                    }
                    else
                    {
                        var oldParent = dragged._parent;
                        InUndoHelper.RecordObjects("Music drag-n-drop", dragged, oldParent, newParent);

                        dragged.MoveToNewParent(newParent);


                        newParent.IsFoldedOut = true;
                    }


                    Event.current.UseEvent();
                });
            }
            else if (newParent._type == MusicNodeType.Music)
            {
                var clips      = objects.Convert(o => o as AudioClip).TakeNonNulls();
                var musicGroup = newParent as InMusicGroup;
                if (musicGroup != null)
                {
                    InUndoHelper.DoInGroup(() =>
                    {
                        InUndoHelper.RecordObject(newParent, "Music Clip Add");
                        foreach (var audioClip in clips)
                        {
                            musicGroup._clips.Add(audioClip);
                        }
                    });
                }
            }
        }
Example #7
0
        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.");
            }
        }