When CoordinateLabeler is in scene i'cant rename objects in hierarchy window

When CoordinateLabeler is in scene i’cant rename objects in hierarchy window
I’m using Unity 2020.3
The code is praticaly the same of the instructor.

Sorry for my bad english. I’m from Brasil and i’m learning english.

here is the code

[ExecuteAlways, RequireComponent(typeof(TextMeshPro))]
public class CoordinateLabeler : MonoBehaviour
{
    private TextMeshPro _label;
    private Vector2Int _coordinates;

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

    private void Update()
    {
        // ReSharper disable once InvertIf
        if (!Application.isPlaying)
        {
            DisplayCoordinates();
            UpdateTileName();
        }
    }

    private void DisplayCoordinates()
    {
        var position = transform.parent.position;
        _coordinates.x = Mathf.RoundToInt(position.x / UnityEditor.EditorSnapSettings.move.x);
        _coordinates.y = Mathf.RoundToInt(position.z / UnityEditor.EditorSnapSettings.move.z);
        _label.text = $"{_coordinates.x},{_coordinates.y}";
    }

    private void UpdateTileName()
    {
        transform.parent.name = _coordinates.ToString();
    }
}```

Hi Luiz,

Have you already tried to restart Unity? If so, which game objects did you try to rename to no avail? Do they have the CoordinateLabeler attached?

Which exact version of Unity do you use? Maybe there is a bug in yours. Generally, it is not advisable to follow with an older version of Unity than the instructor in the video because there might be differences. Gary uses Unity 2021.1.7f1. If possible, please update.

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

Privacy & Terms