using UnityEngine;
using TMPro;
[ExecuteAlways]
public class Coordinate : MonoBehaviour
{
TextMeshPro label;
Vector2Int coordinate = new Vector2Int();
void Awake()
{
label = GetComponent<TextMeshPro>();
}
void Update()
{
// 유니티에서 플레이 화면말고 편집화면일때 아래 구문 실행
if( !Application.isPlaying )
{
coordinate.x = Mathf.RoundToInt(transform.parent.position.x / UnityEditor.EditorSnapSettings.move.x);
coordinate.y = Mathf.RoundToInt(transform.parent.position.z / UnityEditor.EditorSnapSettings.move.z);
label.text = coordinate.x + "," + coordinate.y;
UpdateObjectName();
}
}
void UpdateObjectName()
{
transform.parent.name = coordinate.ToString();
}
}
유니티 코루틴 (1) | 2024.09.04 |
---|---|
유니티 그리드 시스템 적 움직이기 (0) | 2024.09.04 |
유니티 싱글톤 (1) | 2024.09.02 |
유니티 하이어라키 오브젝트 부모 자식 옮기기 (0) | 2024.08.31 |
콜라이더, 트리거 충돌표 (0) | 2024.08.30 |