// [DidReloadScripts(1)] // static void DidReloadScripts() // { // Debug.Log( "Did Reload Scripts" ); // //if( _instance == null ) // //{ // // GetInstance().nodes.Clear(); // // //} // // } public override void OnXGUI() { //TODO List Event e = Event.current; mousePosition = e.mousePosition; if (e.button == 0 || e.button == 1) { ChooseNode(); } bool isFixUpConfig = false; if (e.button == 1 && e.type == EventType.MouseUp) { GraphMenu m = new GraphMenu(SelectedIndex); e.Use(); } else if (e.button == 0 && e.type == EventType.MouseUp && IsTransition) { if (IsClickNode && !SelectedNode.Equals(InputNode)) { SelectedNode.SetInputNode(InputNode, mousePosition); } isFixUpConfig = true; } BeginWindows(); for (int i = 0; i < nodes.Count; i++) { // nodes[i].GraphRect = GUI.Window(i, nodes[i].GraphRect, DrawNodeGraph, nodes[i].GraphTitle); nodes [i].Draw(i); } if (isFixUpConfig) { IsTransition = false; } EndWindows(); if (IsTransition) { DrawTransitionCurve(); } for (int i = 0; i < nodes.Count; i++) { nodes [i].DrawCurves(); } }
public void CreateSubGridAtSelection() { if (SelectedNode.Equals(NavGrid.NO_NODE)) { return; } Vector2Int point = _selectedNode; point.x = Mathf.Clamp(point.x - (_selectedSubGrid.Width / 2), 0, currentNavGrid.Width - 1); point.y = Mathf.Clamp(point.y - (_selectedSubGrid.Height / 2), 0, currentNavGrid.Height - 1); _selectedSubGrid = SubGridGenerator.CreateSubGridAtPoint(currentNavGrid, _selectedSubGrid, point, _NODE_RENDER_LIMIT); SceneView.RepaintAll(); }
//Input Handling public void HandleNodeClick(Vector2Int nodeCoordinates) { //SELECT if (SelectedTool == 0) { if (SelectedNode == nodeCoordinates) { SelectedNode = NavGrid.NO_NODE; } else { SelectedNode = nodeCoordinates; } } //SINGLE if (SelectedTool == 1) { currentNavGrid.TogglePathablity(nodeCoordinates, nodeCoordinates); } //SQUARE if (SelectedTool == 2) { if (SelectedNode.Equals(NavGrid.NO_NODE)) { SelectedNode = nodeCoordinates; } else { //Toggle entire squares of walkable area currentNavGrid.TogglePathablity(SelectedNode, nodeCoordinates); SelectedNode = NavGrid.NO_NODE; } } }