private void OnDestroy() { selectedInPoint = null; selectedOutPoint = null; offset = Vector2.zero; drag = Vector2.zero; if (nodes != null) { nodes.Clear(); } if (connections != null) { connections.Clear(); } }
public EditorNode(Vector2 position, float width, float height, GUIStyle nodeStyle, GUIStyle selectedStyle, GUIStyle inPointStyle, GUIStyle outPointStyle, Action <EditorConnectionPoint> OnClickInPoint, Action <EditorConnectionPoint> OnClickOutPoint, Action <EditorNode> onRemoveClick, int id, bool unlocked, int cost, int[] dependencies) { this.rect = new Rect(position, new Vector2(width, height)); this.style = nodeStyle; this.inPoint = new EditorConnectionPoint(this, EditorconnectionPointType.In, inPointStyle, OnClickInPoint); this.outPoint = new EditorConnectionPoint(this, EditorconnectionPointType.Out, outPointStyle, OnClickOutPoint); this.defaultNodeStyle = nodeStyle; this.selectedNodeStyle = selectedStyle; this.onRemove = onRemoveClick; // Create new Rect and GUIStyle for our title and custom fields float rowHeight = height / 7; this.rectID = new Rect(position.x, position.y + rowHeight, width, rowHeight); this.styleID = new GUIStyle(); this.styleID.alignment = TextAnchor.UpperCenter; this.rectAttackIDLable = new Rect(position.x, position.y + 2 * rowHeight, width / 2, rowHeight); this.rectAttackID = new Rect(position.x + width / 2, position.y + 2 * rowHeight, 30, rowHeight); this.rectUnlocked = new Rect(position.x + width / 2, position.y + 3 * rowHeight, width / 2, rowHeight); this.rectUnlockLabel = new Rect(position.x, position.y + 3 * rowHeight, width / 2, rowHeight); this.styleField = new GUIStyle(); this.styleField.alignment = TextAnchor.UpperRight; this.rectCostLabel = new Rect(position.x, position.y + 4 * rowHeight, width / 2, rowHeight); this.rectCost = new Rect(position.x + width / 2, position.y + 4 * rowHeight, 20, rowHeight); this.unlocked = unlocked; this.treeNode = new TreeNode(); this.treeNode.Tree_ID = id; this.treeNode.IsUnlocked = unlocked; this.treeNode.Cost = cost; this.treeNode.Skill_Dependency = dependencies; this.nodeTitle = new StringBuilder(); this.nodeTitle.Append("ID: "); this.nodeTitle.Append(id); }
private void OnClickOutPoint(EditorConnectionPoint outPoint) { selectedOutPoint = outPoint; if (selectedInPoint != null) { if (selectedOutPoint.EditorNode != selectedInPoint.EditorNode) { CreateConnection(); ClearConnectionSelection(); } else { ClearConnectionSelection(); } } }
private void ClearConnectionSelection() { selectedInPoint = null; selectedOutPoint = null; }
public EditorConnection(EditorConnectionPoint inPoint, EditorConnectionPoint outPoint, Action <EditorConnection> OnClickRemoveConnection) { this.inPoint = inPoint; this.outPoint = outPoint; this.OnClickRemoveConnection = OnClickRemoveConnection; }
private void AddNodesFromCutscene() { selectedInPoint = null; selectedOutPoint = null; if (nodes != null) { nodes.Clear(); } if (connections != null) { connections.Clear(); } foreach (BaseCutsceneNode actualNode in cutsceneManager.nodes) { Vector2 targetPosition; switch (projectionPlane) { case ProjectionPlaneType.XY: targetPosition = new Vector2(actualNode.transform.localPosition.x * -offsetScaleFactor, actualNode.transform.localPosition.y * offsetScaleFactor); break; case ProjectionPlaneType.XZ: targetPosition = new Vector2(actualNode.transform.localPosition.x * offsetScaleFactor, actualNode.transform.localPosition.z * offsetScaleFactor); break; case ProjectionPlaneType.YZ: targetPosition = new Vector2(actualNode.transform.localPosition.z * offsetScaleFactor, actualNode.transform.localPosition.y * offsetScaleFactor); break; default: targetPosition = new Vector2(actualNode.transform.localPosition.x * -offsetScaleFactor, actualNode.transform.localPosition.y * offsetScaleFactor); break; } EditorNode node = new EditorNode(this, actualNode, targetPosition, headerStyle, nodeStyle) { OnRemoveNode = OnClickRemoveNode }; node.PrepareConnections(inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint); nodes.Add(actualNode, node); } foreach (BaseCutsceneNode actualNode in cutsceneManager.nodes) { EditorNode node; nodes.TryGetValue(actualNode, out node); if (node != null) { for (int i = 0; i < actualNode.outputNodes.Count; i++) { if (actualNode.outputNodes[i] != null) { EditorNode targetNode; nodes.TryGetValue(actualNode.outputNodes[i], out targetNode); OnClickInPoint(targetNode.inPoints[0]); OnClickOutPoint(node.outPoints[i]); } } } } }