You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
754 B
39 lines
754 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class RS_LabeledComponent : MonoBehaviour
|
|
{
|
|
[SerializeField] protected string label;
|
|
|
|
[Header("References")]
|
|
[SerializeField] private TMP_Text labelText;
|
|
|
|
private void OnValidate()
|
|
{
|
|
UpdateLabel();
|
|
}
|
|
|
|
private void UpdateLabel()
|
|
{
|
|
if (labelText != null)
|
|
{
|
|
labelText.text = label;
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(labelText.rectTransform);
|
|
}
|
|
OnUpdateLabel();
|
|
}
|
|
|
|
public void SetLabel(string label)
|
|
{
|
|
this.label = label;
|
|
UpdateLabel();
|
|
}
|
|
|
|
protected virtual void OnUpdateLabel()
|
|
{
|
|
|
|
}
|
|
}
|
|
|