BITKit/Src/Unity/Scripts/UX/Core/UXWindow.cs

39 lines
1.0 KiB
C#
Raw Normal View History

2023-06-05 19:57:17 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEngine.Events;
namespace BITKit.UX
{
public interface IWindowComponent : IActivable { }
public class UXWindow : UXElement<VisualElement>
{
IWindowComponent[] components;
public override void Set(bool active)
{
try
{
visualElement.style.display = (active) ? DisplayStyle.Flex : DisplayStyle.None;
}
catch (System.Exception)
{
2023-08-23 01:59:26 +08:00
BIT4Log.Warning(gameObject);
2023-06-05 19:57:17 +08:00
throw;
}
foreach (var x in components)
{
x.SetActive(active);
}
}
public override void OnStart()
{
base.OnStart();
components = GetComponentsInChildren<IWindowComponent>(true);
if(visualElement is null)
{
Debug.Log($"{transform.name} bind failure");
}
}
}
}