添加
This commit is contained in:
@@ -84,6 +84,8 @@ public class GridSelector : MonoBehaviour
|
||||
{
|
||||
return getMapGrid(new Vector2(pos.x,pos.y));
|
||||
}
|
||||
|
||||
|
||||
public Vector2Int getMapGrid(Vector2 pos)
|
||||
{
|
||||
var grid = new Vector2Int();
|
||||
@@ -91,6 +93,10 @@ public class GridSelector : MonoBehaviour
|
||||
grid.y = Mathf.FloorToInt(pos.y / map.sideHeight);
|
||||
return grid;
|
||||
}
|
||||
public Vector2 getPosByGrid(Vector2Int grid)
|
||||
{
|
||||
return new Vector2(grid.x * map.sideWidth + map.sideWidth/2, grid.y * map.sideHeight + map.sideHeight / 2);
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
mapRenderer = GetComponent<MeshRenderer>();
|
||||
|
||||
Reference in New Issue
Block a user