As far as I can tell, my code for both of the scripts is the same, but I can’t get the debug key working. I started with C, and then switched to Z, just in case, still nothing. Here is my script for the `[ExecuteAlways]
public class ComponentLabeler : MonoBehaviour
{
[SerializeField] Color defaultColor = Color.white;
[SerializeField] Color blockedColor = Color.gray;
TextMeshPro label;
Vector2Int coordinates = new Vector2Int();
Waypoint waypoint;
void Awake()
{
label = GetComponent<TextMeshPro>();
label.enabled = false;
waypoint = GetComponentInParent<Waypoint>();
DisplayCoordinates();
}
// Update is called once per frame
void Update()
{
if(!Application.isPlaying)
{
DisplayCoordinates();
UpdateObjectName();
}
ColorCoordinates();
ToggleLabels();
}
void ToggleLabels()
{
if(Input.GetKeyUp(KeyCode.Z))
{
Debug.Log("Debug mode enabled.");
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();
}
}
`