2025-10-17 15:10:19 +08:00
|
|
|
using Core;
|
2025-10-18 11:00:06 +08:00
|
|
|
using TMPro;
|
2025-10-17 15:10:19 +08:00
|
|
|
using UnityEngine;
|
2025-10-18 11:00:06 +08:00
|
|
|
using UnityEngine.UI;
|
|
|
|
using Script.Gameplay.Facility;
|
|
|
|
|
2025-10-17 15:10:19 +08:00
|
|
|
namespace UI
|
|
|
|
{
|
2025-10-18 08:55:38 +08:00
|
|
|
public class EditableComponentViewer : MonoBehaviour
|
2025-10-17 15:10:19 +08:00
|
|
|
{
|
2025-10-18 11:00:06 +08:00
|
|
|
private IEditableComponent _component;
|
|
|
|
[SerializeField] private TMP_Text componentName;
|
|
|
|
[SerializeField] private TMP_Text componentState;
|
|
|
|
[SerializeField] private Button closeButton;
|
|
|
|
public void SetComponent(IEditableComponent component)
|
2025-10-17 15:10:19 +08:00
|
|
|
{
|
2025-10-18 11:00:06 +08:00
|
|
|
_component = component;
|
2025-10-17 15:10:19 +08:00
|
|
|
if (component != null)
|
|
|
|
{
|
2025-10-18 11:00:06 +08:00
|
|
|
closeButton.onClick.AddListener(OnClickButton);
|
|
|
|
RefreshUI();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnClickButton()
|
|
|
|
{
|
|
|
|
_component.IsActive = !_component.IsActive;
|
|
|
|
RefreshUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void RefreshUI()
|
|
|
|
{
|
|
|
|
if (_component != null)
|
|
|
|
{
|
|
|
|
componentName.text = _component.ComponentName;
|
|
|
|
componentState.text = _component.IsActive ? "Active" : "Inactive";
|
2025-10-17 15:10:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|