using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UIElements; using UnityEngine.Events; using Sirenix.OdinInspector; using Cursor = UnityEngine.Cursor; #if UNITY_EDITOR using UnityEditor; #endif namespace BITKit.UX { public interface IPanelComponent : IActivable { } public class UXPanel : UXElement { [Header(Constant.Header.Components)] public UIDocument document; [Header(Constant.Header.Settings)] public bool cursor; public bool allowInput; public bool isAdditive; [Header(Constant.Header.InternalVariables)] IPanelComponent[] components; public override void OnStart() { components = GetComponentsInChildren(true); document.enabled = true; base.OnStart(); } public override void Set(bool active) { document.rootVisualElement.style.display = (active) ? DisplayStyle.Flex : DisplayStyle.None; if (active) RegisterCallback(); else UnRegisterCallback(); foreach (var x in components) { x.SetActive(active); } } public virtual void OnDestroyComponent() { } protected virtual float GetOpacity() { return document.rootVisualElement.style.opacity.value; } protected virtual void SetOpacity(float value) { document.rootVisualElement.style.opacity = new(value); } protected virtual void RegisterCallback() { } protected virtual void UnRegisterCallback() { } [BIT] public void Entry() { BITAppForUnity.ThrowIfNotPlaying(); UXFramework.Enter(gameObject.name); } } #if UNITY_EDITOR [CustomEditor(typeof(UXPanel), true)] public class UXPanelInspector : BITInspector { } #endif }