CoordinateLabel - Real Rush

… I did everything like the Tutor in the video and mine still won’t work… I even copied the whole code at the end:

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

[ExecuteAlways]
public class CoordinateLabeler : MonoBehaviour
{
TextMeshPro label;
Vector2Int coordinates = new Vector2Int();

void Awake() {
    label = GetComponent<TextMeshPro>();
    DisplayCoordinates();
}

void Update()
{
   if(!Application.isPlaying)
   {
       DisplayCoordinates();
       UpdateObjectName();
   } 
}

void DisplayCoordinates() 
{
    coordinates.x = Mathf.RoundToInt(transform.parent.position.x / UnityEditor.EditorSnapSettings.move.x);
    coordinates.y = Mathf.RoundToInt(transform.parent.position.z / UnityEditor.EditorSnapSettings.move.z);

    label.text = coordinates.x + "," + coordinates.y;
}

void UpdateObjectName()
{
    transform.parent.name = coordinates.ToString();
}

}

Is that script attached to the game object?

The code i copy pasted had a different name in the monobehaviour and the script couldn’t be founded

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms