59 lines
1.2 KiB
C#
59 lines
1.2 KiB
C#
using KitsuneCafe.System.Attributes;
|
|
using UnityEngine;
|
|
|
|
namespace KitsuneCafe.UI
|
|
{
|
|
public class TestThing : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private UiOrchestrator orchestrator;
|
|
|
|
[SerializeField]
|
|
private ModalElement modal;
|
|
|
|
[SerializeField]
|
|
private bool hasTitle = true;
|
|
|
|
[SerializeField, ShowIf("hasTitle")]
|
|
private string title;
|
|
|
|
[SerializeField]
|
|
private string content;
|
|
|
|
private ElementId id;
|
|
|
|
public void Open()
|
|
{
|
|
id = orchestrator.SpawnElement(
|
|
Create(),
|
|
transform.position + Vector3.up
|
|
);
|
|
}
|
|
|
|
private IUiElement Create()
|
|
{
|
|
return hasTitle ? modal.Create(title, content) : modal.CreateHeadless(content);
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
if (id != default)
|
|
{
|
|
orchestrator.DespawnElement(id);
|
|
id = default;
|
|
}
|
|
}
|
|
|
|
public void Toggle()
|
|
{
|
|
if (id != default)
|
|
{
|
|
Close();
|
|
}
|
|
else
|
|
{
|
|
Open();
|
|
}
|
|
}
|
|
}
|
|
}
|