wip
This commit is contained in:
@@ -2,23 +2,23 @@ using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class LockToGrid : MonoBehaviour
|
||||
{
|
||||
public int tileSize = 1;
|
||||
public Vector3 tileOffset = Vector3.zero;
|
||||
//[ExecuteInEditMode]
|
||||
//public class LockToGrid : MonoBehaviour
|
||||
//{
|
||||
// public int tileSize = 1;
|
||||
// public Vector3 tileOffset = Vector3.zero;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(!EditorApplication.isPlaying)
|
||||
{
|
||||
Vector3 currentPosition = transform.position;
|
||||
// void Update()
|
||||
// {
|
||||
// if(!EditorApplication.isPlaying)
|
||||
// {
|
||||
// Vector3 currentPosition = transform.position;
|
||||
|
||||
float snappedX = Mathf.Round(currentPosition.x / tileSize) * tileSize + tileOffset.x;
|
||||
float snappedZ = Mathf.Round(currentPosition.z / tileSize) * tileSize + tileOffset.z;
|
||||
// float snappedX = Mathf.Round(currentPosition.x / tileSize) * tileSize + tileOffset.x;
|
||||
// float snappedZ = Mathf.Round(currentPosition.z / tileSize) * tileSize + tileOffset.z;
|
||||
|
||||
var snappedPosition = new Vector3(snappedX, currentPosition.y, snappedZ);
|
||||
transform.position = snappedPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
// var snappedPosition = new Vector3(snappedX, currentPosition.y, snappedZ);
|
||||
// transform.position = snappedPosition;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user