void Click() { Vector3 scenePos = scene.transform.InverseTransformPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition)); Vector2 nodePos = IsoUtil.ScreenToIsoGrid(scene.size, scenePos.x, scenePos.y); int nodeX = (int)nodePos.x; int nodeZ = (int)nodePos.y; if (grid.CheckInGrid(nodeX, nodeZ) && grid.GetNode(nodeX, nodeZ).walkable) { IsoObject obj = (IsoObject)Instantiate(isoObjectPrefab); obj.SetNodePosition(nodeX, nodeZ); if (obj.GetWalkable(grid)) { scene.AddIsoObject(obj); obj.SetNodePosition(nodeX, nodeZ); obj.transform.localScale = Vector3.one; obj.SetWalkable(false, grid); } else { Destroy(obj.gameObject); } } }