private void genericPlaceHere(T p, T n) { InUndoHelper.DoInGroup(() => { InUndoHelper.RecordObjects("Location", p, p._getParent, n, n._getParent); DeattachFromParent(n); if (p._getChildren.Any() && p.IsFoldedOut) { AssignNewParent(p, n, 0); } else if (n._getParent == p._getParent) { var index = p._getParent._getChildren.IndexOf(p); AssignNewParent(p._getParent, n, index + 1); } else { if (!p.IsRoot) { int newIndex = p._getParent._getChildren.IndexOf(p) + 1; AssignNewParent(p._getParent, n, newIndex); } else { int newIndex = p._getChildren.IndexOf(p) + 1; AssignNewParent(p, n, newIndex); } } }); }
public static void DeleteNodeNoGroup(InAudioNode node) { InUndoHelper.RecordObjects("Undo Deletion of " + node.Name, node, node._nodeData, node._parent, node._parent._nodeData); 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); }
protected override void OnDrop(InMusicNode newParent, UnityEngine.Object[] objects) { if (newParent == null || objects == null) { return; } var dragged = objects[0] as InMusicNode; if (dragged != null) { if (dragged.IsRoot || dragged == newParent) { return; } InUndoHelper.DoInGroup(() => { if (dragged.gameObject != newParent.gameObject) { if (EditorUtility.DisplayDialog("Move?", "Warning, this will break all external references to this and all child nodes!\n" + "Move node from\"" + dragged.gameObject.name + "\" to \"" + newParent.gameObject.name + "\"?", "Ok", "Cancel")) { treeDrawer.SelectedNode = TreeWalker.GetPreviousVisibleNode(treeDrawer.SelectedNode); MusicWorker.Duplicate(newParent.gameObject, dragged, newParent); DeleteNodeRec(dragged); AudioBankWorker.RebuildBanks(); } } else { var oldParent = dragged._parent; InUndoHelper.RecordObjects("Music drag-n-drop", dragged, oldParent, newParent); dragged.MoveToNewParent(newParent); newParent.IsFoldedOut = true; } Event.current.UseEvent(); }); } else if (newParent._type == MusicNodeType.Music) { var clips = objects.Convert(o => o as AudioClip).TakeNonNulls(); var musicGroup = newParent as InMusicGroup; if (musicGroup != null) { InUndoHelper.DoInGroup(() => { InUndoHelper.RecordObject(newParent, "Music Clip Add"); foreach (var audioClip in clips) { musicGroup._clips.Add(audioClip); } }); } } }