public static AudioNode CreateChild(AudioNode parent, AudioNodeType newNodeType)
        {
            Undo.RegisterSceneUndo("Child creation");
            OnRandomNode(parent);

            var child = CreateNode(parent.gameObject, parent, GUIDCreator.Create(), newNodeType);

            parent.FoldedOut = true;
            child.Name       = "Name";
            child.BankLink   = AudioBankWorker.GetParentBank(child);
            AddDataClass(child);
            return(child);
        }
        public static void AddNewParent(AudioNode node, AudioNodeType parentType)
        {
            var newParent = CreateNode(node.gameObject, node.Parent, parentType);
            var oldParent = node.Parent;

            newParent.Bus       = node.Bus;
            newParent.FoldedOut = true;
            newParent.BankLink  = AudioBankWorker.GetParentBank(oldParent);
            int index = oldParent.Children.FindIndex(node);

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

            OnRandomNode(newParent);

            NodeWorker.RemoveFromParent(newParent);
            oldParent.Children.Insert(index, newParent);
        }
        public static void DeleteNode(AudioNode node)
        {
            for (int i = node.Children.Count - 1; i > 0; --i)
            {
                DeleteNode(node.Children[i]);
            }

            if (node.Parent.Type == AudioNodeType.Random) //We also need to remove the child from the weight list
            {
                var data = node.Parent.NodeData as RandomData;
                if (data != null)
                {
                    data.weights.RemoveAt(node.Parent.Children.FindIndex(node)); //Find in parent, and then remove the weight in the random node
                }
            }

            AudioBankWorker.RemoveNodeFromBank(node);

            node.Parent.Children.Remove(node);
            Object.DestroyImmediate(node.NodeData, true);
            Object.DestroyImmediate(node, true);
        }