Beispiel #1
0
        static void OnDrawGizmosSelected(NavGrid grid, GizmoType type)
        {
            if (currentMode != NavGridTool3DGUI.Mode.RENDER)
            {
                return;
            }

            NavGridTool tool = EditorWindow.GetWindow(typeof(NavGridTool), false, "", false) as NavGridTool;

            //Draw each node
            for (int y = 0; y < grid.Height; y++)
            {
                for (int x = 0; x < grid.Width; x++)
                {
                    Gizmos.color = tool.ChooseNodeColor(new Vector2Int(x, y));
                    Gizmos.DrawCube(grid.GetOriginWorldPosition() + new Vector3(x, 0, y), Vector3.one * 0.45f);
                }
            }
        }
Beispiel #2
0
        private void DrawNodeHandles(NavGridTool tool, SubGrid subGrid)
        {
            float NODE_SIZE = 0.45f;

            NavGrid navGrid = subGrid.GetNavGrid();

            Vector2Int subGridOriginPosition = subGrid.GetOriginCoordinate();
            Vector3    subGridWorldPosition  = navGrid.GetOriginWorldPosition() + new Vector3(subGridOriginPosition.x, 0, subGridOriginPosition.y);

            int width  = subGrid.Width;
            int height = subGrid.Height;

            //Draw each node
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Vector2Int nodeCoordinates =
                        new Vector2Int(
                            subGridOriginPosition.x + x,
                            subGridOriginPosition.y + y
                            );

                    Handles.color = tool.ChooseNodeColor(nodeCoordinates);

                    if (currentMode == Mode.EDIT)
                    {
                        //Draw nodes as buttons and watch for input
                        if (Handles.Button(subGridWorldPosition + new Vector3(x, 0, y), Quaternion.LookRotation(Vector3.up), NODE_SIZE, NODE_SIZE, Handles.CubeHandleCap))
                        {
                            HandleNodeClick(subGrid, nodeCoordinates);
                        }
                    }
                }
            }
        }