private Rect GetNodeBounds(NodeTree graph, Rect container, bool bound = false) { var minX = float.PositiveInfinity; var minY = float.PositiveInfinity; var maxX = float.NegativeInfinity; var maxY = float.NegativeInfinity; for (var i = 0; i < graph.AllNodes.Count; i++) { minX = Mathf.Min(minX, graph.AllNodes[i].NodeRect.xMin); minY = Mathf.Min(minY, graph.AllNodes[i].NodeRect.yMin); maxX = Mathf.Max(maxX, graph.AllNodes[i].NodeRect.xMax); maxY = Mathf.Max(maxY, graph.AllNodes[i].NodeRect.yMax); } minX -= 50; minY -= 50; maxX += 50; maxY += 50; if (bound) { minX = Mathf.Min(minX, container.xMin + 50); minY = Mathf.Min(minY, container.yMin + 50); maxX = Mathf.Max(maxX, container.xMax - 50); maxY = Mathf.Max(maxY, container.yMax - 50); } return(Rect.MinMaxRect(minX, minY, maxX, maxY)); }
void OnInspectorUpdate() { if (EditorUtility.InstanceIDToObject(mTreeInstanceID) is NodeTree) { mTree = EditorUtility.InstanceIDToObject(mTreeInstanceID) as NodeTree; Repaint(); } }
public static BTTreeWindow OpenWindow(NodeTree tree) { var window = EditorWindow.GetWindow <BTTreeWindow>(); window.mTreeInstanceID = tree.GetInstanceID(); window.mTree = tree; window.mTree.FocusedNode = null; window.mTree.UpdateGraphIDs(); return(window); }
public static Node CreateNode(NodeTree tree, System.Type graphType) { GameObject child = new GameObject(graphType.ToString(), graphType); return((Node)child.GetComponent(graphType)); }