void ContextCallback(object obj) { switch (obj.ToString()) { case "0": NodePopupWindow.InitNodePopup(); break; case "1": NodeUtils.LoadGraph(); break; case "2": NodeUtils.UnloadGraph(); break; case "3": NodeUtils.CreateNode(currentGraph, NodeType.Float, mousePosition); break; case "4": NodeUtils.CreateNode(currentGraph, NodeType.Add, mousePosition); break; case "5": NodeUtils.DeleteNode(deleteNodeId, currentGraph); break; default: break; } }
void GraphContextMenu(AbstractView view, Event e) { AbstractNode curNode = curGraph?.GetNode(e.mousePosition); if (curNode != null) { return; } GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Create Graph"), false, delegate() { NodePopupWindow.InitNodePopup(delegate(NodeGraph graph) { OnGraphChange?.Invoke(graph); }); }); menu.AddItem(new GUIContent("Load Graph"), false, delegate() { OnGraphChange?.Invoke(NodeUtils.LoadGraph()); }); if (curGraph != null) { menu.AddSeparator(""); menu.AddItem(new GUIContent("Unload Graph"), false, delegate() { OnGraphChange?.Invoke(null); }); menu.AddSeparator(""); NodeUtils.GetEnumerableOfType <AbstractNode>().ForEach(delegate(Type t) { menu.AddItem(new GUIContent(t.Name), false, delegate() { NodeUtils.CreateNode(curGraph, t, e.mousePosition); }); }); } menu.ShowAsContext(); e.Use(); }
static void CreateNode(object p_nodeType) { float zoom = DashEditorCore.EditorConfig.zoom; Vector2 offset = DashEditorCore.EditorConfig.editingGraph.viewOffset; Vector2 position = new Vector2(_lastMousePosition.x * zoom - offset.x, _lastMousePosition.y * zoom - offset.y); NodeUtils.CreateNode(DashEditorCore.EditorConfig.editingGraph, (Type)p_nodeType, position); }
static void CreateAnimationNodesFromSelection(object p_nodeType) { Transform[] selectedTransforms = SelectionUtils.GetTransformsFromSelection(); float zoom = DashEditorCore.EditorConfig.zoom; Vector2 viewOffset = DashEditorCore.EditorConfig.editingGraph.viewOffset; Vector2 position = new Vector2(_lastMousePosition.x * zoom - viewOffset.x, _lastMousePosition.y * zoom - viewOffset.y); Vector2 offset = Vector2.zero; foreach (Transform transform in selectedTransforms) { NodeBase node = NodeUtils.CreateNode(DashEditorCore.EditorConfig.editingGraph, (Type)p_nodeType, position + offset); if (node != null) { RetargetNodeModelBase model = node.GetModel() as RetargetNodeModelBase; model.retarget = true; //model.target.SetValue(transform.name); model.useReference = true; IExposedPropertyTable propertyTable = DashEditorCore.EditorConfig.editingController; bool isDefault = PropertyName.IsNullOrEmpty(model.targetReference.exposedName); if (isDefault) { PropertyName newExposedName = new PropertyName(GUID.Generate().ToString()); model.targetReference.exposedName = newExposedName; propertyTable.SetReferenceValue(newExposedName, transform); //p_fieldInfo.SetValue(p_object, exposedReference); } else { propertyTable.SetReferenceValue(model.targetReference.exposedName, transform); } // If its bindable bind all values to current transform if (node is IAnimationNodeBindable) { ((IAnimationNodeBindable)node).GetTargetFrom(transform); ((IAnimationNodeBindable)node).GetTargetTo(transform); } offset.y += node.Size.y + 24; } } }
void ContextCallBack(object obj) { switch (obj.ToString()) { case "0": NodePopupWindow.InitNodePopup(); break; case "1": NodeUtils.LoadGraph(); break; case "2": NodeUtils.UnloadGraph(); break; case "3": NodeUtils.CreateNode(curGraph, NodeType.Input, mousePos); break; case "4": NodeUtils.CreateNode(curGraph, NodeType.Adjust, mousePos); break; case "5": NodeUtils.CreateNode(curGraph, NodeType.Output, mousePos); break; case "6": NodeUtils.DeleteNode(deleteNodeID, curGraph); break; default: break; } }