Toggle Label only shows not placeable coords

(“I found the issue wasnt in the code Issue was for some reason the prefab varients had Double c# coordiante labler srcipts dont know how that happend it got messy so i redid the whole scene and all prefabs and works fine now”)
Hello i double checked my code and tried a few variants but when i toggle the label only the nonplaceable coors show up hers my code hope you guys can help me figure it out

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using TMPro;

[ExecuteAlways]

public class CoordianteLabeler : MonoBehaviour

{

[SerializeField] Color defaultColor = Color.white;

[SerializeField] Color blockedColor = Color.grey;

TextMeshPro label;

Vector2Int coordinates = new Vector2Int();

Waypoint waypoint;

void Awake()

{

    label = GetComponent<TextMeshPro>();    

    label.enabled = false;

   

    waypoint = GetComponentInParent<Waypoint>();

    DisplayCoordinates();

}

void Update()

{

    if(!Application.isPlaying)

    {

        DisplayCoordinates();

        UpdateObjectName();

       

    }

    ColorCoordinates();

    ToggleLabels();

}

void ToggleLabels()

{

    if(Input.GetKeyDown(KeyCode.C))

    {

        label.enabled = !label.IsActive();

    }

}

void ColorCoordinates()

{

    if(waypoint.IsPlaceable)

    {

        label.color = defaultColor;

    }

    else

    {

        label.color = blockedColor;

    }

}

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();

 }

}

Hi @dusty7765,

Does that mean you fixed the issue?

Yes i did Nina thks.

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

Privacy & Terms