public override void OnInspectorGUI()
    {
        PathfindingGrid pathfindingGrid = (PathfindingGrid)target;

        pathfindingGrid.obstacleMask         = EditorTools.LayerMaskField("Obstacle Mask", pathfindingGrid.obstacleMask);
        pathfindingGrid.gridWorldSizeX       = EditorGUILayout.FloatField("Grid World Size X", pathfindingGrid.gridWorldSizeX);
        pathfindingGrid.gridWorldSizeZ       = EditorGUILayout.FloatField("Grid World Size Z", pathfindingGrid.gridWorldSizeZ);
        pathfindingGrid.nodeRadius           = EditorGUILayout.FloatField("Node Radius", pathfindingGrid.nodeRadius);
        pathfindingGrid.distanceBetweenNodes = EditorGUILayout.FloatField("Distance Between Nodes", pathfindingGrid.distanceBetweenNodes);

        if (GUILayout.Button("Generate"))
        {
            pathfindingGrid.GenerateGrid();
            EditorUtility.SetDirty(pathfindingGrid);
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        currentMode = (EditingMode)dd.value;
        EditGrid();

        if (gridSlider.value != gridSize)
        {
            grid.gridSize = 10 * (int)gridSlider.value;
            grid.nodeSize = 0.5f / gridSlider.value;
            pathfinderObject.transform.localScale = new Vector2(grid.nodeSize, grid.nodeSize);
            targetNode.transform.localScale       = new Vector2(grid.nodeSize, grid.nodeSize);
            grid.GenerateGrid();
        }
        gridSize = gridSlider.value;

        // Reset colors if trying to edit grid
        if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
        {
            for (int i = 0; i < grid.nodes.Length; i++)
            {
                grid.nodes[i].updateNodeObject();
            }
        }
    }