示例#1
0
        public static bool CanBeDuckedBy(InAudioBus selectedNode, InAudioBus dragging)
        {
            var draggingBus = dragging;

            if (draggingBus == null)
            {
                return(false);
            }
            //Does it already exist in the collection?
            if (selectedNode.DuckedBy.TrueForAny(data => data.DuckedBy == dragging))
            {
                return(false);
            }

            if (draggingBus.IsRoot)
            {
                return(false);
            }

            if (NodeWorker.IsChildOf(selectedNode, draggingBus))
            {
                return(false);
            }

            if (NodeWorker.IsParentOf(selectedNode.GetParent, draggingBus))
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        public static void Duplicate(InAudioNode audioNode)
        {
            UndoHelper.DoInGroup(() =>
            {
                List <Object> toUndo = TreeWalker.FindAll(audioNode, node => node.GetBank().LazyBankFetch).ConvertList <InAudioBank, Object>();

                toUndo.Add(audioNode.Parent);
                toUndo.Add(audioNode.GetBank());

                UndoHelper.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)
                    {
                        Type type        = oldNode.NodeData.GetType();
                        newNode.NodeData = gameObject.AddComponentUndo(type) as InAudioNodeBaseData;
                        EditorUtility.CopySerialized(oldNode.NodeData, newNode.NodeData);
                        if (newNode.Type == AudioNodeType.Audio)
                        {
                            AudioBankWorker.AddNodeToBank(newNode, (oldNode.NodeData as InAudioData).EditorClip);
                        }
                    }
                });
            });
        }
示例#3
0
        //Draw all nodes recursively
        void DrawTree(T node, int indentLevel)
        {
            if (node != null)
            {
                if (node.IsFiltered)
                {
                    return;
                }
                EditorGUI.indentLevel = indentLevel + 1;
                DrawNode(node);
                EditorGUI.indentLevel = indentLevel - 1;

                if (!node.IsFoldedOut)
                {
                    return;
                }

                if (Event.current.type == EventType.Layout)
                {
                    NodeWorker.RemoveNullChildren(node);
                }
                for (int i = 0; i < node.GetChildren.Count; ++i)
                {
                    T child = node.GetChildren[i];
                    DrawTree(child, indentLevel + 1);
                }
            }
        }
示例#4
0
        public static bool CanDropObjects(InAudioEventNode audioEvent, Object[] objects)
        {
            if (objects.Length == 0 || audioEvent == null)
            {
                return(false);
            }

            if (audioEvent.Type == EventNodeType.Event)
            {
                bool bankLinkDrop;
                bool audioBusDrop;
                var  audioNodeDrop = CanDropNonEvent(objects, out bankLinkDrop, out audioBusDrop);

                return(audioNodeDrop | bankLinkDrop | audioBusDrop);
            }
            else if (audioEvent.Type == EventNodeType.Folder || audioEvent.Type == EventNodeType.Root)
            {
                var draggingEvent = objects[0] as InAudioEventNode;
                if (draggingEvent != null)
                {
                    if (draggingEvent.Type == EventNodeType.Event)
                    {
                        return(true);
                    }
                    if ((draggingEvent.Type == EventNodeType.Folder && !NodeWorker.IsChildOf(draggingEvent, audioEvent)) ||
                        draggingEvent.Type == EventNodeType.EventGroup)
                    {
                        return(true);
                    }
                }
                else
                {
                    bool bankLinkDrop;
                    bool audioBusDrop;
                    var  audioNodeDrop = CanDropNonEvent(objects, out bankLinkDrop, out audioBusDrop);

                    return(audioNodeDrop | bankLinkDrop | audioBusDrop);
                }
            }
            else if (audioEvent.Type == EventNodeType.EventGroup)
            {
                var draggingEvent = objects[0] as InAudioEventNode;
                if (draggingEvent == null)
                {
                    return(false);
                }
                if (draggingEvent.Type == EventNodeType.Event)
                {
                    return(true);
                }
            }


            return(false);
        }
示例#5
0
 public static InAudioEventNode Duplicate(InAudioEventNode audioEvent)
 {
     return(NodeWorker.DuplicateHierarchy(audioEvent, (@oldNode, newNode) =>
     {
         newNode.ActionList.Clear();
         for (int i = 0; i < oldNode.ActionList.Count; i++)
         {
             newNode.ActionList.Add(NodeWorker.CopyComponent(oldNode.ActionList[i]));
         }
     }));
 }
示例#6
0
        public static bool OnDrop(InAudioEventNode audioevent, Object[] objects)
        {
            UndoHelper.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;

                    UndoHelper.RecordObjectFull(new Object[] { audioevent, movingEvent, movingEvent.Parent }, "Event Move");
                    NodeWorker.ReasignNodeParent((InAudioEventNode)objects[0], audioevent);
                    audioevent.IsFoldedOut = true;
                }

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

                var audioBank = objects[0] as InAudioBankLink;
                if (audioBank != null)
                {
                    UndoHelper.RecordObjectFull(audioevent, "Adding of Bank Load Action");
                    var action = AddEventAction <InEventBankLoadingAction>(audioevent,
                                                                           EventActionTypes.BankLoading);
                    action.BankLink = audioBank;
                }

                var audioBus = objects[0] as InAudioBus;
                if (audioBus != null)
                {
                    UndoHelper.RecordObjectFull(audioevent, "Adding of Bus Volume");
                    var action = AddEventAction <InEventBusAction>(audioevent, EventActionTypes.SetBusVolume);
                    action.Bus = audioBus;
                }
                Event.current.Use();
            });
            return(true);
        }
示例#7
0
        public static void AddNewParent(InAudioNode node, AudioNodeType parentType)
        {
            UndoHelper.RecordObject(new Object[] { node, node.Parent, node.GetBankDirect() }, "Undo Add New Parent for " + node.Name);
            var newParent = CreateNode(node.gameObject, node.Parent, parentType);
            var oldParent = node.Parent;

            newParent.Bus       = node.Bus;
            newParent.FoldedOut = true;
            if (node.Type == AudioNodeType.Folder)
            {
                InFolderData data = (InFolderData)newParent.NodeData;
                data.BankLink = oldParent.GetBank();
            }
            int index = oldParent.Children.FindIndex(node);

            NodeWorker.RemoveFromParent(node);
            node.AssignParent(newParent);

            OnRandomNode(newParent);

            NodeWorker.RemoveFromParent(newParent);
            oldParent.Children.Insert(index, newParent);
        }