Ejemplo n.º 1
0
    protected override void OnDrop(AudioBankLink node, Object[] objects)
    {
        AudioBankLink target = objects[0] as AudioBankLink;

        //Undo.RegisterUndo(new Object[] { node, target, target.Parent}, "Drag and Drop bank move");
        NodeWorker.ReasignNodeParent(target, node);
    }
    protected override void OnDrop(AudioBus node, Object[] objects)
    {
        var target = objects[0] as AudioBus;

        Undo.RegisterUndo(new Object[] { node, target, target.Parent }, "Bus Move");
        NodeWorker.ReasignNodeParent(target, node);
    }
Ejemplo n.º 3
0
    protected override void OnDrop(InAudioBus dropOn, Object[] objects)
    {
        var beingDragged = objects[0] as InAudioBus;

        UndoHelper.RecordObject(new Object[] { dropOn, beingDragged, beingDragged.Parent }, "Bus drag n drop");

        NodeWorker.ReasignNodeParent(beingDragged, dropOn);
    }
Ejemplo n.º 4
0
    protected override void OnDrop(AudioNode node, UnityEngine.Object[] objects)
    {
        if (objects[0] as AudioNode != null) //Drag N Drop internally in the tree, change the parent
        {
            node.IsFoldedOut = true;
            var           nodeToMove = objects[0] as AudioNode;
            var           oldBank    = AudioBankWorker.GetParentBank(nodeToMove);
            AudioBankLink newBank    = null;
            if (nodeToMove.OverrideParentBank)
            {
                newBank = AudioBankWorker.GetParentBank(nodeToMove);
            }
            else
            {
                newBank = AudioBankWorker.GetParentBank(node);
            }
            Undo.RegisterUndo(new UnityEngine.Object[] { node, nodeToMove, nodeToMove.Parent, oldBank, newBank }, "Audio Node Move");
            NodeWorker.ReasignNodeParent(nodeToMove, node);
            AudioBankWorker.MoveNode(nodeToMove, oldBank);
        }
        else if (node.Type != AudioNodeType.Audio) //Create new audio nodes when we drop clips
        {
            for (int i = 0; i < objects.Length; ++i)
            {
                var clip  = objects[i] as AudioClip;
                var child = AudioNodeWorker.CreateChild(node, AudioNodeType.Audio);
                var path  = AssetDatabase.GetAssetPath(clip);
                try
                {
                    //Try and get the name of the clip. Gets the name and removes the end. Assets/IntroSound.mp3 -> IntroSound
                    int lastIndex = path.LastIndexOf('/') + 1;
                    child.Name = path.Substring(lastIndex, path.LastIndexOf('.') - lastIndex);
                }
                catch (Exception) //If it happens to be a mutant path. Not even sure if this is possible, but better safe than sorry
                {
                    child.Name = node.Name + " Child";
                }

                (child.NodeData as AudioData).EditorClip = clip;
                AudioBankWorker.AddNodeToBank(child, clip);
                Event.current.Use();
            }
        }
        else //Then it must be an audio clip dropped on an audio node, so assign the clip to that node
        {
            var bank = AudioBankWorker.GetParentBank(node);
            Undo.RegisterUndo(new UnityEngine.Object[] { node, bank.LazyBankFetch, node.NodeData }, "Undo Changing Node In Bank");
            (node.NodeData as AudioData).EditorClip = objects[0] as AudioClip;
            AudioBankWorker.SwapClipInBank(node, objects[0] as AudioClip);
        }
    }
        public static void OnDrop(AudioEvent audioevent, Object[] objects)
        {
            if (objects.Length == 1)
            {
                if (objects[0] as AudioEvent)
                {
                    var movingEvent = objects[0] as AudioEvent;
                    Undo.RegisterUndo(new Object[] { audioevent, movingEvent, movingEvent.Parent }, "Event Move");
                    NodeWorker.ReasignNodeParent((AudioEvent)objects[0], audioevent);
                    audioevent.IsFoldedOut = true;
                }

                var audioNode = objects[0] as AudioNode;
                if (audioNode != null && audioNode.IsPlayable)
                {
                    var action = AddEventAction <EventAudioAction>(audioevent,
                                                                   EventActionTypes.Play);
                    action.Node = audioNode;
                }

                var audioBank = objects[0] as AudioBankLink;
                if (audioBank != null)
                {
                    var action = AddEventAction <EventBankAction>(audioevent,
                                                                  EventActionTypes.LoadBank);
                    action.BankLink = audioBank;
                }

                var audioBus = objects[0] as AudioBus;
                if (audioBus != null)
                {
                    var action = AddEventAction <EventBusAction>(audioevent,
                                                                 EventActionTypes.SetBusVolume);
                    action.Bus = audioBus;
                }
                Event.current.Use();
            }
        }