44 lines
974 B
C#
44 lines
974 B
C#
using EnglewoodLAB.Object;
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace EnglewoodLAB.UI
|
|
{
|
|
|
|
[RequireComponent(typeof(Button))]
|
|
public class CameraControlItem : MonoBehaviour
|
|
{
|
|
public CameraPoint point;
|
|
public int floorIndex;
|
|
private Button button;
|
|
|
|
public Action<CameraControlItem> OnItemClicked;
|
|
|
|
public void SettingButton(CameraPoint point)
|
|
{
|
|
gameObject.name = $"{point.name}_Button";
|
|
|
|
this.point = point;
|
|
floorIndex = point.floorIndex;
|
|
|
|
button = GetComponent<Button>();
|
|
var buttonText = GetComponentInChildren<TMP_Text>();
|
|
|
|
if (buttonText != null)
|
|
{
|
|
buttonText.SetText(point.name);
|
|
}
|
|
|
|
button.onClick.AddListener(HandleClick);
|
|
}
|
|
|
|
private void HandleClick()
|
|
{
|
|
OnItemClicked?.Invoke(this);
|
|
}
|
|
}
|
|
}
|
|
|