40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using Core;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Script.Gameplay.Interface;
|
|
|
|
namespace UI
|
|
{
|
|
public class EditableComponentViewer : MonoBehaviour
|
|
{
|
|
private IEditableComponent _component;
|
|
[SerializeField] private TMP_Text componentName;
|
|
[SerializeField] private TMP_Text componentState;
|
|
[SerializeField] private Button closeButton;
|
|
public void SetComponent(IEditableComponent component)
|
|
{
|
|
_component = component;
|
|
if (component != null)
|
|
{
|
|
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";
|
|
}
|
|
}
|
|
}
|
|
} |