using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class DiscretePositioning : MonoBehaviour
{
    public bool enab;
    public Vector2 phase;
    public Vector2 mod;

//#if UNITY_EDITOR
    // Update is called once per frame
    void Update()
    {
        if (Application.isEditor && !Application.isPlaying)
        {
            if (mod.x == 0 || mod.y == 0) return;
            Vector3 v = new Vector3(transform.position.x - phase.x, transform.position.y - phase.y, transform.position.z);
            Vector3 u = new Vector3(Mathf.Round(v.x / mod.x) * mod.x + phase.x, Mathf.Round(v.y / mod.y) * mod.y + phase.y, v.z);
            transform.position = u;
        }
    }
//#endif
}
