GameOff2024/Assets/Scripts/UI/NavElementUI.cs

31 lines
718 B
C#

using System;
using UnityEngine;
using UnityEngine.UI;
namespace GameOff.UI
{
public class NavElementUI : MonoBehaviour
{
[SerializeField] private Transform section;
[SerializeField] private Text title;
[SerializeField] private Button button;
private void Start()
{
title.text = section.name;
button.onClick.AddListener(() => section.SetAsLastSibling());
}
private void OnValidate()
{
if(section)
{
title.text = section.name;
transform.name = $"{section.name} - NavElementUI";
}
else
title.text = "None";
}
}
}