void OnPaste() { if (clipboard == null) { return; } if (!IsValidParent(clipboard, reactor.hotNode)) { ShowNotification(new GUIContent("Active node is an invalid parent.")); EditorApplication.Beep(); return; } var node = BaseNode.Clone(clipboard); var parent = reactor.hotNode as IParentNode; if (parent != null) { Undo.RegisterCompleteObjectUndo(target, "Paste"); parent.Add(node); } else { Undo.RegisterCompleteObjectUndo(target, "Paste"); parent = reactor.hotNode.nodeParent as IParentNode; parent.Insert(parent.IndexOf(reactor.hotNode), node); } reactor.hotNode = node; EditorUtility.SetDirty(target); }
void OnDuplicate() { Undo.RecordObject(target, "Duplicate"); if (!IsValidParent(reactor.hotNode, reactor.hotNode.nodeParent)) { ShowNotification(new GUIContent("You cannot duplicate this node.")); EditorApplication.Beep(); return; } var dupe = BaseNode.Clone(reactor.hotNode); var parent = reactor.hotNode.nodeParent as IParentNode; var index = parent.IndexOf(reactor.hotNode); parent.Insert(index + 1, dupe); reactor.hotNode = dupe; EditorUtility.SetDirty(target); }
void PerformDrag() { Undo.RecordObject(target, "Drag & Drop"); var oldParent = dragNode.nodeParent as IParentNode; var newParent = dropZone.parent as IParentNode; if (ReactTypeRegister.IsCoreDecorator(dragNode.GetType()) && newParent != root) { EditorApplication.Beep(); return; } newParent.Insert(dropZone.index, BaseNode.Clone(dragNode)); if (!Event.current.shift) { oldParent.Remove(dragNode); } ExitDrag(); }
internal bool AddSuperCall(Reactor lib, string superID) { if (!IsValidParent(typeof(SuperCall), reactor.hotNode)) { ShowNotification(new GUIContent("Active node is an invalid parent.")); EditorApplication.Beep(); return(false); } var newNode = Activator.CreateInstance(typeof(SuperCall)) as SuperCall; newNode.lib = lib; newNode.id = superID; var branch = reactor.hotNode as BranchNode; if (branch != null) { branch.Add(newNode); } var decorator = reactor.hotNode as DecoratorNode; if (decorator != null) { decorator.SetChild(newNode); } reactor.hotNode = newNode; var super = lib.GetExport(superID); if (super != null) { foreach (var p in super.ParameterNodes) { newNode.Add(BaseNode.Clone(p)); } } focusFirstControl = true; EditorUtility.SetDirty(target); Repaint(); return(true); }
void OnCopy() { clipboard = BaseNode.Clone(reactor.hotNode); }