// Use this for initialization void Start() { grid = Grid2D.instance; // setup GUI resizer - only for the demo GUIResizer.Init(800, 500); labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleLeft; labelStyle.normal.textColor = Color.white; // Configure the grid crossing cost depending on the textures for (int k = 0; k < grid.cells.Count; k++) { int textureIndex = grid.CellGetTextureIndex(k); if (textureIndex == 2) { grid.CellSetCrossCost(k, 10); } else { grid.CellSetCrossCost(k, 1); } } // Hook into cell click event to toggle start selection or draw a computed path using A* path finding algorithm grid.OnCellClick += BuildPath; // Position the token tokenRow = grid.rowCount - 1; tokenColumn = 5; Vector3 position = grid.CellGetPosition(tokenRow, tokenColumn); token.transform.position = position; // Prepare move points and show available positions movePoints = 10; }