Exemplo n.º 1
0
        private static void SetPitch(InAudioNodeData baseData)
        {
            float minPitch = 0.001f;
            float maxPitch = 3;

            InUndoHelper.GUIUndo(baseData, "Random Pitch", ref baseData.RandomPitch, () =>
                                 EditorGUILayout.Toggle("Random Pitch", baseData.RandomPitch));

            if (!baseData.RandomPitch)
            {
                InUndoHelper.GUIUndo(baseData, "Pitch", () =>
                                     EditorGUILayout.Slider("Pitch", baseData.MinPitch, minPitch, maxPitch),
                                     v =>
                {
                    baseData.MinPitch = v;
                    if (baseData.MinPitch > baseData.MaxPitch)
                    {
                        baseData.MaxPitch = baseData.MinPitch + 0.1f;
                    }
                    baseData.MaxPitch = Mathf.Clamp(baseData.MaxPitch, minPitch, 3.0f);
                });
            }
            else
            {
                InUndoHelper.GUIUndo(baseData, "Random Pitch",
                                     ref baseData.MinPitch, ref baseData.MaxPitch,
                                     (out float v1, out float v2) =>
                {
                    EditorGUILayout.MinMaxSlider(new GUIContent("Pitch"), ref baseData.MinPitch, ref baseData.MaxPitch,
                                                 minPitch, maxPitch);
                    v1 = Mathf.Clamp(EditorGUILayout.FloatField("Min pitch", baseData.MinPitch), minPitch, baseData.MaxPitch);
                    v2 = Mathf.Clamp(EditorGUILayout.FloatField("Max pitch", baseData.MaxPitch), baseData.MinPitch, maxPitch);
                });
            }
        }
Exemplo n.º 2
0
        public static void Duplicate(InAudioNode audioNode)
        {
            InUndoHelper.DoInGroup(() =>
            {
                List <Object> toUndo = new List <Object>();

                toUndo.Add(audioNode._parent);
                toUndo.AddRange(audioNode._parent.GetAuxData());

                InUndoHelper.RecordObjectFull(toUndo.ToArray(), "Undo Duplication Of " + audioNode.Name);

                if (audioNode._parent._type == AudioNodeType.Random)
                {
                    (audioNode._parent._nodeData as RandomData).weights.Add(50);
                }
                NodeWorker.DuplicateHierarchy(audioNode, (@oldNode, newNode) =>
                {
                    var gameObject = audioNode.gameObject;
                    if (oldNode._nodeData != null)
                    {
                        NodeDuplicate(oldNode, newNode, gameObject);
                    }
                });
            });
        }
Exemplo n.º 3
0
        private static void SetSpatialBlend(InAudioNodeData baseData)
        {
            float minBlend = 0;
            float maxBlend = 1;

            InUndoHelper.GUIUndo(baseData, "Random Spatial Blend", ref baseData.RandomBlend, () =>
                                 EditorGUILayout.Toggle("Random Spatial Blend", baseData.RandomBlend));

            if (!baseData.RandomBlend)
            {
                InUndoHelper.GUIUndo(baseData, "Blend", () =>
                                     EditorGUILayout.Slider("Blend (2D <-> 3D)", baseData.MinBlend, minBlend, maxBlend),
                                     v =>
                {
                    baseData.MinBlend = v;
                    if (baseData.MinBlend > baseData.MaxBlend)
                    {
                        baseData.MaxBlend = baseData.MinBlend + 0.1f;
                    }
                    baseData.MaxBlend = Mathf.Clamp(baseData.MaxBlend, minBlend, 3.0f);
                });
            }
            else
            {
                InUndoHelper.GUIUndo(baseData, "Random Pitch",
                                     ref baseData.MinBlend, ref baseData.MaxBlend,
                                     (out float v1, out float v2) =>
                {
                    EditorGUILayout.MinMaxSlider(new GUIContent("Blend (2D <-> 3D)"), ref baseData.MinBlend, ref baseData.MaxBlend,
                                                 minBlend, maxBlend);
                    v1 = Mathf.Clamp(EditorGUILayout.FloatField("Min Blend", baseData.MinBlend), minBlend, baseData.MaxBlend);
                    v2 = Mathf.Clamp(EditorGUILayout.FloatField("Max Blend", baseData.MaxBlend), baseData.MinBlend, maxBlend);
                });
            }
        }
Exemplo n.º 4
0
        public static void DrawVolume(Object undoObj, ref float refMinVolume, ref float refMaxVolume, ref bool refRandomVolume)
        {
            float minVolume    = refMinVolume;
            float maxVolume    = refMaxVolume;
            bool  randomVolume = refRandomVolume;

            InUndoHelper.GUIUndo(undoObj, "Random Volume", ref randomVolume, () => EditorGUILayout.Toggle("Random Volume", randomVolume));

            if (!randomVolume)
            {
                InUndoHelper.GUIUndo(undoObj, "Volume", () => EditorGUILayout.Slider("Volume", minVolume, 0, 1), v =>
                {
                    minVolume = v;
                    if (minVolume > maxVolume)
                    {
                        maxVolume = Mathf.Clamp01(minVolume + 0.1f);
                    }
                });
            }
            else
            {
                InUndoHelper.GUIUndo(undoObj, "Random Volume", ref minVolume, ref maxVolume, (out float newMinVolume, out float newMaxVolume) =>
                {
                    EditorGUILayout.MinMaxSlider(new GUIContent("Volume"), ref minVolume, ref maxVolume, 0, 1);
                    newMinVolume = Mathf.Clamp(EditorGUILayout.FloatField("Min volume", minVolume), 0, maxVolume);
                    newMaxVolume = Mathf.Clamp(EditorGUILayout.FloatField("Max volume", maxVolume), minVolume, 1);
                });
            }
            refMinVolume    = minVolume;
            refMaxVolume    = maxVolume;
            refRandomVolume = randomVolume;
        }
Exemplo n.º 5
0
        public static void Draw(InAudioNode node)
        {
            var nodeData = node._nodeData;

            EditorGUILayout.BeginVertical();
            var data = node._nodeData as InFolderData;


            #region Mixer
            DataDrawerHelper.DrawMixer(node);
            #endregion
            EditorGUILayout.Separator();
            #region Volume
            if (Application.isPlaying)
            {
                InUndoHelper.GUIUndo(nodeData, "Folder volume", ref data.runtimeVolume, () => EditorGUILayout.Slider("Runtime Volume", data.runtimeVolume, 0, 1));
            }
            else
            {
                InUndoHelper.GUIUndo(nodeData, "Folder volume", ref data.VolumeMin, () => EditorGUILayout.Slider("Initial Volume", data.VolumeMin, 0, 1));
            }
            #endregion

            EditorGUILayout.EndVertical();
        }
Exemplo n.º 6
0
 private void genericPlaceHere(T p, T n)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjects("Location", p, p._getParent, n, n._getParent);
         DeattachFromParent(n);
         if (p._getChildren.Any() && p.IsFoldedOut)
         {
             AssignNewParent(p, n, 0);
         }
         else if (n._getParent == p._getParent)
         {
             var index = p._getParent._getChildren.IndexOf(p);
             AssignNewParent(p._getParent, n, index + 1);
         }
         else
         {
             if (!p.IsRoot)
             {
                 int newIndex = p._getParent._getChildren.IndexOf(p) + 1;
                 AssignNewParent(p._getParent, n, newIndex);
             }
             else
             {
                 int newIndex = p._getChildren.IndexOf(p) + 1;
                 AssignNewParent(p, n, newIndex);
             }
         }
     });
 }
Exemplo n.º 7
0
        public static void MoveNodeOneUp <T>(T node) where T : Object, InITreeNode <T>
        {
            if (node is InAudioNode)//As parent could be a random one, it needs to record this first
            {
                InUndoHelper.RecordObject(new Object[] { node._getParent, (node._getParent as InAudioNode)._nodeData },
                                          "Undo Reorder Of " + node.GetName);
            }
            else
            {
                InUndoHelper.RecordObject(new Object[] { node._getParent }, "Undo Reorder Of " + node.GetName);
            }

            var children = node._getParent._getChildren;
            var index    = children.IndexOf(node);

            if (index != 0 && children.Count > 0)
            {
                //TODO Remove hack
                if (node.GetType() == typeof(InAudioNode))
                {
                    var audioNode = node as InAudioNode;
                    if (audioNode._parent._type == AudioNodeType.Random)
                    {
                        (audioNode._parent._nodeData as RandomData).weights.SwapAtIndexes(index, index - 1);
                    }
                }
                children.SwapAtIndexes(index, index - 1);
            }
        }
Exemplo n.º 8
0
        private static int Cleanup <T>(T audioRoot) where T : MonoBehaviour, InITreeNode <T>
        {
            if (audioRoot == null)
            {
                return(0);
            }

            HashSet <MonoBehaviour> objects = new HashSet <MonoBehaviour>();
            var allNodes = audioRoot.GetComponents <MonoBehaviour>();

            for (int i = 0; i < allNodes.Length; ++i)
            {
                objects.Add(allNodes[i]);
            }

            TreeWalker.ForEach(audioRoot, obj =>
            {
                objects.Add(obj);
                obj.GetAuxData().ForEach(o => objects.Add(o));
            });

            int deleted = 0;

            //Delete all objects not in use
            foreach (MonoBehaviour node in objects)
            {
                if (!objects.Contains(node))
                {
                    deleted += 1;
                    InUndoHelper.PureDestroy(node);
                }
            }
            return(deleted);
        }
Exemplo n.º 9
0
        private static void DeleteNodeRec(InAudioNode node)
        {
            AudioBankWorker.RemoveNodeFromBank(node);

            /*TreeWalker.ForEach(InAudioInstanceFinder.DataManager.EventTree, @event =>
             * {
             *  for (int i = 0; i < @event.ActionList.Count; i++)
             *  {
             *      var action = @event.ActionList[i];
             *      if (action.Target == node)
             *      {
             *          UndoHelper.RegisterFullObjectHierarchyUndo(action);
             *      }
             *  }
             * });*/

            for (int i = 0; i < node._children.Count; i++)
            {
                DeleteNodeRec(node._children[i]);
            }


            InUndoHelper.Destroy(node._nodeData);
            InUndoHelper.Destroy(node);
        }
Exemplo n.º 10
0
        private static int Cleanup <T>(T audioRoot, Action <T, HashSet <MonoBehaviour> > traverse) where T : MonoBehaviour
        {
            if (audioRoot == null)
            {
                return(0);
            }


            HashSet <MonoBehaviour> objects = new HashSet <MonoBehaviour>();
            var allNodes = audioRoot.GetComponents <MonoBehaviour>();

            for (int i = 0; i < allNodes.Length; ++i)
            {
                objects.Add(allNodes[i]);
            }

            HashSet <MonoBehaviour> inUse = new HashSet <MonoBehaviour>();

            traverse(audioRoot, inUse);

            int deleted = 0;

            //Delete all objects not in use
            foreach (MonoBehaviour node in objects)
            {
                if (!inUse.Contains(node))
                {
                    deleted += 1;
                    InUndoHelper.PureDestroy(node);
                }
            }
            return(deleted);
        }
Exemplo n.º 11
0
        protected override void OnDrop(InAudioBankLink node, Object[] objects)
        {
            InUndoHelper.DragNDropUndo(node, "Bank Drag N Drop");
            InAudioBankLink target = objects[0] as InAudioBankLink;

            NodeWorker.ReasignNodeParent(target, node);
        }
Exemplo n.º 12
0
        public static void Draw(InAudioNode node)
        {
            node.ScrollPosition = GUILayout.BeginScrollView(node.ScrollPosition);

            InUndoHelper.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();

            var clip = (AudioClip)EditorGUILayout.ObjectField(audioData.AudioClip, 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.IsLoaded);
                GUI.enabled = true;
            }

            AudioSource source = InAudioInstanceFinder.Instance.GetComponent <AudioSource>();

            AudioPreview(node, source, audioData);


            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            if (clip != audioData.AudioClip) //Assign new clip
            {
                InUndoHelper.RecordObjectFull(audioData, "Changed " + node.Name + " Clip");
                audioData.AudioClip = clip;
                EditorUtility.SetDirty(node._nodeData.gameObject);
            }

            EditorGUILayout.EndHorizontal();

            if (clip != null)
            {
                DrawImportSettings(clip);
            }

            NodeTypeDataDrawer.Draw(node);

            GUILayout.EndScrollView();
        }
Exemplo n.º 13
0
        public static void ChangeBankOverride(InMusicFolder node)
        {
            var all = GetAllBanks();

            InUndoHelper.RecordObject(all.ToArray().AddObj(node), "Changed Bank");
            node._overrideParentBank = !node._overrideParentBank;
            RebuildBanks();
        }
Exemplo n.º 14
0
        public static InSettingsNode CreateSettingsTree(GameObject go, int level)
        {
            var node = InUndoHelper.AddComponent <InSettingsNode>(go);

            node.GetName = "Settings";
            node._ID     = GUIDCreator.Create();
            return(node);
        }
Exemplo n.º 15
0
 private void DeleteNodeRec(InMusicNode toDelete)
 {
     for (int i = 0; i < toDelete._children.Count; i++)
     {
         DeleteNodeRec(toDelete._children[i]);
     }
     InUndoHelper.Destroy(toDelete);
 }
 public static void Draw(InAudioNode node)
 {
     node.ScrollPosition = GUILayout.BeginScrollView(node.ScrollPosition);
     InUndoHelper.GUIUndo(node, "Name Change", ref node.Name, () =>
                          EditorGUILayout.TextField("Name", node.Name));
     NodeTypeDataDrawer.Draw(node);
     GUILayout.EndScrollView();
 }
Exemplo n.º 17
0
        public static bool OnDrop(InAudioEventNode audioevent, Object[] objects)
        {
            InUndoHelper.DoInGroup(() =>
            {
                //if (audioevent.Type == EventNodeType.Folder)
                //{
                //    UndoHelper.RecordObjectInOld(audioevent, "Created event");
                //    audioevent = CreateNode(audioevent, EventNodeType.Event);
                //}

                if (objects[0] as InAudioEventNode)
                {
                    var movingEvent = objects[0] as InAudioEventNode;


                    if (movingEvent.gameObject != audioevent.gameObject)
                    {
                        if (EditorUtility.DisplayDialog("Move?",
                                                        "Warning, this will break all external references to this and all child nodes!\n" +
                                                        "Move node from\"" + movingEvent.gameObject.name +
                                                        "\" to \"" + audioevent.gameObject.name + "\"?", "Ok", "Cancel"))
                        {
                            InUndoHelper.DoInGroup(() =>
                            {
                                CopyTo(movingEvent, audioevent);
                                DeleteNodeNoGroup(movingEvent);
                            });
                        }
                    }
                    else
                    {
                        InUndoHelper.RecordObjectFull(new Object[] { audioevent, movingEvent, movingEvent._parent }, "Event Move");
                        NodeWorker.ReasignNodeParent(movingEvent, audioevent);
                        audioevent.EditorSettings.IsFoldedOut = true;
                    }
                }

                var audioNode = objects[0] as InAudioNode;
                if (audioNode != null && audioNode.IsPlayable)
                {
                    InUndoHelper.RecordObjectFull(audioevent, "Adding of Audio Action");
                    var action = AddEventAction <InEventAudioAction>(audioevent,
                                                                     EventActionTypes.Play);
                    action.Node = audioNode;
                }

                var musicGroup = objects[0] as InMusicGroup;
                if (musicGroup != null)
                {
                    InUndoHelper.RecordObjectFull(audioevent, "Adding of Music Action");
                    var action = AddEventAction <InEventMusicControl>(audioevent,
                                                                      EventActionTypes.PlayMusic);
                    action.MusicGroup = musicGroup;
                }
                Event.current.UseEvent();
            });
            return(true);
        }
 public static void DeleteNode(InAudioEventNode node)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RegisterUndo(node._parent, "Event Deletion");
         node._parent._children.Remove(node);
         DeleteNodeRec(node);
     });
 }
Exemplo n.º 19
0
 public static void DeleteBank(InAudioBankLink toDelete)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObject(InAudioInstanceFinder.DataManager.AudioTree.gameObject.GetComponents <MonoBehaviour>().Add(toDelete).Add(InAudioInstanceFinder.DataManager.MusicTree.gameObject.GetComponents <MonoBehaviour>()), "Bank detele");
         toDelete._parent._getChildren.Remove(toDelete);
         InUndoHelper.Destroy(toDelete);
     });
 }
Exemplo n.º 20
0
 public static void DeleteFolder(InAudioBankLink toDelete)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjectFull(toDelete._parent, "Delete Bank Folder");
         toDelete._parent._getChildren.Remove(toDelete);
         InUndoHelper.Destroy(toDelete);
     });
 }
Exemplo n.º 21
0
 private void CreateMusicGroup(InMusicNode parent)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjectFull(parent, "Create Music Folder");
         parent.FoldedOut = true;
         MusicWorker.CreateMusicGroup(parent);
     });
 }
Exemplo n.º 22
0
 private void CreateFolder(InMusicNode parent)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjectFull(parent, "Create Music Folder");
         parent.EditorSettings.IsFoldedOut = true;
         MusicWorker.CreateFolder(parent.gameObject, parent);
     });
 }
        public static AudioEventAction AddEventAction(InAudioEventNode audioevent, Type eventActionType, EventActionTypes enumType)
        {
            InUndoHelper.RecordObject(audioevent, "Event Action Creation");
            var eventAction = audioevent.gameObject.AddComponentUndo(eventActionType) as AudioEventAction;

            audioevent._actionList.Add(eventAction);
            eventAction._eventActionType = enumType;

            return(eventAction);
        }
        public static InAudioEventNode DeleteActionAtIndex(InAudioEventNode audioevent, int index)
        {
            InUndoHelper.RecordObject(audioevent, "Event Action Creation");
            InUndoHelper.Destroy(audioevent._actionList[index]);


            audioevent._actionList.RemoveAt(index);

            return(audioevent);
        }
Exemplo n.º 25
0
        private void CreateChild(InAudioEventNode node, EventNodeType type)
        {
            InUndoHelper.DoInGroup(() =>
            {
                InUndoHelper.RegisterUndo(node, "Event Creation");
                AudioEventWorker.CreateNode(node, type);
            });

            node.EditorSettings.IsFoldedOut = true;
        }
Exemplo n.º 26
0
        private static void DeleteNodeRec(InAudioNode node)
        {
            for (int i = 0; i < node._children.Count; i++)
            {
                DeleteNodeRec(node._children[i]);
            }

            InUndoHelper.Destroy(node._nodeData);
            InUndoHelper.Destroy(node);
        }
Exemplo n.º 27
0
        public static void ChangeAudioNodeBank(InAudioNode node, InAudioBankLink newBank)
        {
            var all = GetAllBanks();

            InUndoHelper.RecordObject(all.ToArray().AddObj(node._nodeData), "Changed Bank");
            InFolderData data = (node._nodeData as InFolderData);

            data.BankLink = newBank;
            RebuildBanks();
        }
Exemplo n.º 28
0
        public static void ChangeMusicNodeBank(InMusicNode node, InAudioBankLink newBank)
        {
            var all = GetAllBanks();

            InUndoHelper.RecordObject(all.ToArray().AddObj(node), "Changed Bank");
            InMusicFolder data = (node as InMusicFolder);

            data._bankLink = newBank;
            RebuildBanks();
        }
Exemplo n.º 29
0
        public static void ChangeBankOverride(InAudioNode node)
        {
            var all = GetAllBanks();

            InUndoHelper.RecordObject(all.ToArray().AddObj(node._nodeData), "Changed Bank");
            InFolderData data = (node._nodeData as InFolderData);

            data.OverrideParentBank = !data.OverrideParentBank;
            RebuildBanks();
        }
Exemplo n.º 30
0
        private static void MoveNode(InAudioNode node, InAudioNode nodeToMove)
        {
            InUndoHelper.RecordObject(
                new UnityEngine.Object[]
                { node, node._nodeData, node._parent, node._parent != null ? node._parent._nodeData : null, nodeToMove._parent._nodeData, nodeToMove, nodeToMove._parent, nodeToMove._parent._nodeData }.AddObj(),
                "Audio Node Move");

            NodeWorker.ReasignNodeParent(nodeToMove, node);
            Event.current.UseEvent();
        }