Esempio n. 1
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);
                    }
                });
            });
        }
Esempio n. 2
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();
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 public static void DeleteFolder(InAudioBankLink toDelete)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjectFull(toDelete._parent, "Delete Bank Folder");
         toDelete._parent._getChildren.Remove(toDelete);
         InUndoHelper.Destroy(toDelete);
     });
 }
Esempio n. 5
0
 private void CreateFolder(InMusicNode parent)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjectFull(parent, "Create Music Folder");
         parent.EditorSettings.IsFoldedOut = true;
         MusicWorker.CreateFolder(parent.gameObject, parent);
     });
 }
Esempio n. 6
0
 private void CreateMusicGroup(InMusicNode parent)
 {
     InUndoHelper.DoInGroup(() =>
     {
         InUndoHelper.RecordObjectFull(parent, "Create Music Folder");
         parent.FoldedOut = true;
         MusicWorker.CreateMusicGroup(parent);
     });
 }
Esempio n. 7
0
        public static void RemoveNodeFromBank(InAudioNode node)
        {
            var bankLink = node.GetBank();

            if (bankLink != null)
            {
                InUndoHelper.RecordObjectFull(bankLink, "Node from bank removal");
                var bank = bankLink._bankData;
                bank.RemoveAll(b => b.AudioNode == node);
            }
        }
Esempio n. 8
0
        private void CreateChild(InAudioNode parent, AudioNodeType type)
        {
            InUndoHelper.RecordObjectFull(new UnityEngine.Object[] { parent, parent.GetBank() },
                                          "Create Audio Node");
            var newNode = AudioNodeWorker.CreateChild(parent, type);

            if (type == AudioNodeType.Audio)
            {
                AudioBankWorker.AddNodeToBank(newNode);
            }
        }
Esempio n. 9
0
        public static void Draw(InAudioNode node)
        {
            //node.ScrollPosition = GUILayout.BeginScrollView(node.ScrollPosition);

            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));


            selectedArea = GUILayout.SelectionGrid(selectedArea, new [] { "Track", "Standard Settings" }, 2);
            EditorGUILayout.HelpBox("Hold control to drag a child node onto a track.", MessageType.None);

            if (selectedArea == 1)
            {
                NodeTypeDataDrawer.Draw(node);
            }
            else
            {
                EditorGUILayout.BeginVertical();
                ScrollArea = EditorGUILayout.BeginScrollView(ScrollArea, false, false);
                EditorGUILayout.BeginVertical();

                foreach (var layer in trackData.Layers)
                {
                    DrawItem(node, layer);
                }

                if (GUILayout.Button("Add Layer", GUILayout.Width(150)))
                {
                    InUndoHelper.RecordObjectFull(trackData, "Add layer");
                    trackData.Layers.Add(new InLayerData());
                }


                EditorGUILayout.EndVertical();
                EditorGUILayout.EndScrollView();
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();
            if (toRemove != null)
            {
                if (trackData.Layers.Remove(toRemove))
                {
                    GUI.FocusControl("none");
                    InUndoHelper.RegisterUndo(trackData, "Removed Layer");
                }
            }
            //GUILayout.EndScrollView();
        }
Esempio n. 10
0
 private void CreateBank(InAudioBankLink parent, AudioBankTypes type)
 {
     //TODO make real undo
     InUndoHelper.RecordObjectFull(parent, "Bank " + (type == AudioBankTypes.Folder ? "Folder " : "") + "Creation");
     if (type == AudioBankTypes.Folder)
     {
         AudioBankWorker.CreateFolder(parent.gameObject, parent, GUIDCreator.Create());
     }
     else
     {
         AudioBankWorker.CreateBankLink(parent.gameObject, parent, GUIDCreator.Create());
     }
 }
Esempio n. 11
0
        public void Move(int sourceIndex, int destIndex)
        {
            InUndoHelper.RecordObjectFull(Event, "Reorder Event Actions");
            if (destIndex > sourceIndex)
            {
                --destIndex;
            }

            var item = Event._actionList[sourceIndex];

            Event._actionList.RemoveAt(sourceIndex);
            Event._actionList.Insert(destIndex, item);
        }
Esempio n. 12
0
        public static void ConvertNodeType(InAudioNode node, AudioNodeType newType)
        {
            if (newType == node._type)
            {
                return;
            }
            InUndoHelper.DoInGroup(() =>
            {
                InUndoHelper.RecordObjectFull(new Object[] { node, node._nodeData }, "Change Node Type");

                node._type = newType;
                InUndoHelper.Destroy(node._nodeData);
                AddDataClass(node);
            });
        }
Esempio n. 13
0
        private static float DrawItem(InAudioNode node, InLayerData item)
        {
            EditorGUILayout.BeginVertical(GUILayout.Height(220));
            var trackData = node._nodeData as InTrackData;


            EditorGUILayout.BeginHorizontal();


            EditorGUILayout.BeginVertical(GUILayout.Width(150));
            GUILayout.Label("Left");
            GUILayout.Label("Inside left");
            InUndoHelper.GUIUndo(trackData, "Zoom", ref item.Zoom, () => Math.Max(0, EditorGUILayout.FloatField("Zoom", item.Zoom)));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Delete Layer"))
            {
                InUndoHelper.RecordObjectFull(trackData, "Remove layer");
                {
                    toRemove = item;
                }
            }
            EditorGUILayout.Separator();
            EditorGUILayout.EndVertical();

            Rect dragArea = EditorGUILayout.BeginVertical();

            //GUILayout.Label("Right");
            item.ScrollPos = EditorGUILayout.BeginScrollView(item.ScrollPos, false, false);
            GUILayout.Label("Hello");
            Rect start = GUILayoutUtility.GetLastRect();
            var  t     = new Texture2D(1, 1);

            t.SetPixel(0, 0, Color.white);
            GUI.DrawTexture(start, t, ScaleMode.StretchToFill);
            //start.y += 20;
            //GUI.Label(start, "Hello");

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
            //EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            DropAreaGUI <InAudioNode>(dragArea, item, otherNode => !TreeWalker.IsParentOf(node, otherNode) || node == otherNode, AfterDrag);

            return(0);
        }
Esempio n. 14
0
        public static void DrawMixer(InMusicNode node, SerializedProperty prop)
        {
            if (!node.IsRoot)
            {
                bool overrideParent = EditorGUILayout.Toggle("Override Parent Mixer", node._overrideParentMixerGroup);
                if (overrideParent != node._overrideParentMixerGroup)
                {
                    InUndoHelper.RecordObjectFull(node, "Override parent mixer group");
                    node._overrideParentMixerGroup = overrideParent;
                }
                if (!node._overrideParentMixerGroup)
                {
                    GUI.enabled = false;
                }
            }
            EditorGUILayout.BeginHorizontal();

            if (node._overrideParentMixerGroup)
            {
                EditorGUILayout.PropertyField(prop, new GUIContent("Mixer Group"));
            }
            else
            {
                if (node._parent != null)
                {
                    var parentProp = new SerializedObject(node.GetParentMixing());
                    parentProp.Update();
                    EditorGUILayout.PropertyField(parentProp.FindProperty("_mixerGroup"),
                                                  new GUIContent("Parent Mixer Group"));
                    parentProp.ApplyModifiedProperties();
                }
                else
                {
                    var parentProp = new SerializedObject(node);
                    parentProp.Update();
                    EditorGUILayout.PropertyField(parentProp.FindProperty("_mixerGroup"), new GUIContent("Mixer Group"));
                    parentProp.ApplyModifiedProperties();
                }
            }

            GUI.enabled = node.GetParentMixing() != null;
            if (GUILayout.Button("Find", GUILayout.Width(40)))
            {
                SearchHelper.SearchFor(node._mixerGroup);
            }
            EditorGUILayout.EndHorizontal();
            GUI.enabled = true;
        }
Esempio n. 15
0
        public static void CopyTo(InAudioNode audioNode, InAudioNode newParent)
        {
            List <Object> toUndo = new List <Object>();

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

            InUndoHelper.RecordObjectFull(toUndo.ToArray(), "Undo Move");

            NodeWorker.DuplicateHierarchy(audioNode, newParent, newParent.gameObject, (@oldNode, newNode) =>
            {
                var gameObject = newParent.gameObject;
                if (oldNode._nodeData != null)
                {
                    NodeDuplicate(oldNode, newNode, gameObject);
                }
            });
        }
        public static void Draw(InAudioBankLink bankLink)
        {
            EditorGUILayout.BeginVertical();

            InUndoHelper.GUIUndo(bankLink, "Name Change", ref bankLink._name, () =>
                                 EditorGUILayout.TextField("Name", bankLink._name));

            if (bankLink._type == AudioBankTypes.Bank)
            {
                EditorGUIHelper.DrawID(bankLink._guid);

                //UndoHelper.GUIUndo(bankLink, "Load async", ref bankLink.LoadASync, () =>
                //    EditorGUILayout.Toggle("Load ASync", bankLink.LoadASync));

                bool autoLoad = EditorGUILayout.Toggle("Auto load", bankLink._autoLoad);
                if (autoLoad != bankLink._autoLoad) //Value has changed
                {
                    InUndoHelper.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);
        }
Esempio n. 17
0
        public static void DrawMixer(InAudioNode node)
        {
            var serialized = new SerializedObject(node);

            serialized.Update();
            if (!node.IsRoot)
            {
                bool overrideParent = EditorGUILayout.Toggle("Override Parent Mixer Group", node.OverrideParentMixerGroup);
                if (overrideParent != node.OverrideParentMixerGroup)
                {
                    InUndoHelper.RecordObjectFull(new Object[] { node._nodeData, node }, "Override parent mixer group");
                    node.OverrideParentMixerGroup = overrideParent;
                }
                if (!node.OverrideParentMixerGroup)
                {
                    GUI.enabled = false;
                }
            }

            EditorGUILayout.BeginHorizontal();

            if (node.IsRoot)
            {
                EditorGUILayout.PropertyField(serialized.FindProperty("MixerGroup"), new GUIContent("Mixer Group"));
            }
            else if (node.OverrideParentMixerGroup)
            {
                EditorGUILayout.PropertyField(serialized.FindProperty("MixerGroup"), new GUIContent("Mixer Group"));
            }
            else
            {
                EditorGUILayout.PropertyField(new SerializedObject(node.GetParentMixerGroup()).FindProperty("MixerGroup"), new GUIContent("Parent Mixer Group"));
            }

            GUI.enabled = node.GetMixerGroup() != null;
            if (GUILayout.Button("Find", GUILayout.Width(40)))
            {
                SearchHelper.SearchFor(node.MixerGroup);
            }
            EditorGUILayout.EndHorizontal();
            serialized.ApplyModifiedProperties();
            GUI.enabled = true;
        }
Esempio n. 18
0
 private void CreateChild(InAudioNode parent, AudioNodeType type)
 {
     InUndoHelper.RecordObjectFull(new UnityEngine.Object[] { parent },
                                   "Create Audio Node");
     AudioNodeWorker.CreateChild(parent, type);
 }
Esempio n. 19
0
        public static void MarkAllBanksForUndo()
        {
            List <Object> toUndo = new List <Object>(GetAllBanks().ConvertAll(b => b as Object));

            InUndoHelper.RecordObjectFull(toUndo.ToArray(), "Undo Duplication");
        }