コード例 #1
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);
                        }
                    }
                });
            });
        }
コード例 #2
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]));
         }
     }));
 }