private static void DeleteNodeRec(InAudioNode node) { AudioBankWorker.RemoveNodeFromBank(node); /*TreeWalker.ForEach(InAudioInstanceFinder.DataManager.EventTree, @event => * { * for (int i = 0; i < @event.ActionList.Count; i++) * { * var action = @event.ActionList[i]; * if (action.Target == node) * { * UndoHelper.RegisterFullObjectHierarchyUndo(action); * } * } * });*/ for (int i = 0; i < node.Children.Count; i++) { DeleteNodeRec(node.Children[i]); } UndoHelper.Destroy(node.NodeData); UndoHelper.Destroy(node); }
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); } } }); }); }
public static void DeleteBus(InAudioBus bus, InAudioNode root) { UndoHelper.DoInGroup(() => { UndoHelper.RecordObjectFull(bus.Parent, "Bus deletion"); bus.Parent.Children.Remove(bus); HashSet <InAudioBus> toDelete = new HashSet <InAudioBus>(); GetBusesToDelete(toDelete, bus); var runtimePlayers = bus.RuntimePlayers; if (runtimePlayers != null) { for (int i = 0; i < runtimePlayers.Count; ++i) { runtimePlayers[i].SetNewBus(bus.Parent); } } List <InAudioNode> affectedNodes = new List <InAudioNode>(); //Get all affected nodes TreeWalker.FindAllNodes(root, node => toDelete.Contains(node.GetBus()), affectedNodes); toDelete.ToArray().ForEach(UndoHelper.Destroy); for (int i = 0; i < affectedNodes.Count; ++i) { affectedNodes[i].Bus = bus.Parent; } }); }
public static void MoveNodeOneUp <T>(T node) where T : Object, InITreeNode <T> { if (node is InAudioNode)//As parent could be a random one, it needs to record this first { UndoHelper.RecordObject(new Object[] { node.GetParent, (node.GetParent as InAudioNode).NodeData }, "Undo Reorder Of " + node.GetName); } else { UndoHelper.RecordObject(new Object[] { node.GetParent }, "Undo Reorder Of " + node.GetName); } var children = node.GetParent.GetChildren; var index = children.IndexOf(node); if (index != 0 && children.Count > 0) { //TODO Remove hack if (node.GetType() == typeof(InAudioNode)) { var audioNode = node as InAudioNode; if (audioNode.Parent.Type == AudioNodeType.Random) { (audioNode.Parent.NodeData as RandomData).weights.SwapAtIndexes(index, index - 1); } } children.SwapAtIndexes(index, index - 1); } }
public static void DeleteFolder(InAudioBankLink toDelete) { UndoHelper.DoInGroup(() => { UndoHelper.RecordObjectFull(toDelete.Parent, "Delete Bank Folder"); toDelete.Parent.GetChildren.Remove(toDelete); UndoHelper.Destroy(toDelete); }); }
public static void DeleteNode(InAudioEventNode node) { UndoHelper.DoInGroup(() => { UndoHelper.RegisterUndo(node.Parent, "Event Deletion"); node.Parent.Children.Remove(node); DeleteNodeRec(node); }); }
public static AudioEventAction AddEventAction(InAudioEventNode audioevent, Type eventActionType, EventActionTypes enumType) { UndoHelper.RecordObject(audioevent, "Event Action Creation"); var eventAction = audioevent.gameObject.AddComponentUndo(eventActionType) as AudioEventAction; audioevent.ActionList.Add(eventAction); eventAction.EventActionType = enumType; return(eventAction); }
public static void ChangeBankOverride(InAudioNode node, InAudioBankLink rootBank, InAudioNode root) { var all = TreeWalker.FindAll(rootBank, link => link.Type == AudioBankTypes.Link ? link.LazyBankFetch : null); UndoHelper.RecordObject(all.ToArray().AddObj(node.NodeData), "Changed Bank"); InFolderData data = (node.NodeData as InFolderData); data.OverrideParentBank = !data.OverrideParentBank; RebuildBanks(rootBank, root); }
public static InAudioEventNode DeleteActionAtIndex(InAudioEventNode audioevent, int index) { UndoHelper.RecordObject(audioevent, "Event Action Creation"); UndoHelper.Destroy(audioevent.ActionList[index]); audioevent.ActionList.RemoveAt(index); return(audioevent); }
public static void RemoveNodeFromBank(InAudioNode node) { var bankLink = node.GetBank(); if (bankLink != null) { var bank = bankLink.LazyBankFetch; UndoHelper.RecordObjectFull(bank, "Node from bank removal"); bank.Clips.RemoveAll(p => p.Node == node); } }
private static void DeleteNodeRec(InAudioEventNode node) { for (int i = 0; i < node.ActionList.Count; i++) { UndoHelper.Destroy(node.ActionList[i]); } for (int i = 0; i < node.Children.Count; ++i) { DeleteNodeRec(node.Children[i]); } UndoHelper.Destroy(node); }
public void Move(int sourceIndex, int destIndex) { UndoHelper.RecordObjectFull(Event, "Reorder Event Actions"); if (destIndex > sourceIndex) { --destIndex; } var item = Event.ActionList[sourceIndex]; Event.ActionList.RemoveAt(sourceIndex); Event.ActionList.Insert(destIndex, item); }
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); }
public static void ConvertNodeType(InAudioNode node, AudioNodeType newType) { if (newType == node.Type) { return; } UndoHelper.DoInGroup(() => { UndoHelper.RecordObjectFull(new Object[] { node, node.NodeData }, "Change Node Type"); AudioBankWorker.RemoveNodeFromBank(node); node.Type = newType; UndoHelper.Destroy(node.NodeData); AddDataClass(node); }); }
public static InAudioNode CreateChild(InAudioNode parent, AudioNodeType newNodeType) { var bank = parent.GetBank(); UndoHelper.RecordObject(UndoHelper.Array(parent, parent.NodeData, bank != null ? bank.LazyBankFetch : null), "Undo Node Creation"); OnRandomNode(parent); var child = CreateNode(parent.gameObject, parent, GUIDCreator.Create(), newNodeType); parent.FoldedOut = true; child.Name = parent.Name + " Child"; var data = AddDataClass(child); if (newNodeType == AudioNodeType.Folder) { (data as InFolderData).BankLink = parent.GetBank(); } return(child); }
public static void DeleteNode(InAudioNode node) { UndoHelper.DoInGroup(() => { //UndoHelper.RecordObjectFull(UndoHelper.Array(node.Parent, node.Parent.AudioData), "Undo Deletion of " + node.Name); 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 } node.Parent.Children.Remove(node); } DeleteNodeRec(node); }); }
public static void ReplaceActionDestructiveAt(InAudioEventNode audioEvent, EventActionTypes enumType, int toRemoveAndInsertAt) { //A reel mess this function. //It adds a new component of the specied type, replaces the current at the toRemoveAndInsertAt index, and then deletes the old one float delay = audioEvent.ActionList[toRemoveAndInsertAt].Delay; Object target = audioEvent.ActionList[toRemoveAndInsertAt].Target; var newActionType = ActionEnumToType(enumType); UndoHelper.Destroy(audioEvent.ActionList[toRemoveAndInsertAt]); //UndoHelper.RecordObject(audioEvent, "Event Action Creation"); audioEvent.ActionList.RemoveAt(toRemoveAndInsertAt); var added = AddEventAction(audioEvent, newActionType, enumType); added.Delay = delay; added.Target = target; //Attempt to set the new value, will only work if it is the same type audioEvent.ActionList.Insert(toRemoveAndInsertAt, added); audioEvent.ActionList.RemoveLast(); }
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); }