Neg_Utils/NEG/UI/UnityUi/Window/MonoWindow.cs
2023-01-27 15:31:25 +01:00

52 lines
1.5 KiB
C#

using NEG.UI.Area;
using NEG.UI.UnityUi.WindowSlot;
using NEG.UI.Window;
using NEG.UI.WindowSlot;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace NEG.UI.UnityUi.Window
{
public class MonoWindow : MonoBehaviour, IWindow
{
public IWindowSlot Parent { get; private set; }
public IWindowSlot ChildWindowSlot => childWindowArea;
[SerializeField] private MonoWindowSlot childWindowArea;
[SerializeField] private WindowController controller;
void IWindow.SetOpenedState(IWindowSlot parentSlot)
{
gameObject.SetActive(true);
Parent = parentSlot;
if (controller != null)
controller.OnOpened();
}
public void SetData(object data)
{
if (controller != null)
controller.SetData(data);
}
void IWindow.SetClosedState()
{
gameObject.SetActive(false);
Parent = null;
if(childWindowArea != null)
ChildWindowSlot.CloseAllWindows();
}
private void Awake() => ((IWindow)this).SetClosedState();
private void OnValidate()
{
if (controller == null)
controller = GetComponent<WindowController>();
}
public IEnumerable<IWindowSlot> AvailableSlots { get; }
public void OpenWindow(IWindow window, object data = null) => throw new NotImplementedException();
}
}