1
This commit is contained in:
@@ -13,6 +13,17 @@ namespace BITKit.UX
|
||||
{
|
||||
public class UIToolKitPanel : MonoBehaviour,IUXPanel
|
||||
{
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
private static void Reload()
|
||||
{
|
||||
|
||||
inputActionGroup = new InputActionGroup
|
||||
{
|
||||
allowGlobalActivation = false,
|
||||
Source = nameof(UIToolKitPanel)
|
||||
};
|
||||
inputActionGroup.allowInput.AddElement(0);
|
||||
}
|
||||
public UIToolKitPanel()
|
||||
{
|
||||
Index = GetType().FullName;
|
||||
@@ -29,13 +40,14 @@ namespace BITKit.UX
|
||||
[SerializeField] private Optional<float> entryDuration;
|
||||
[SerializeField] private Optional<float> exitDuration;
|
||||
|
||||
protected readonly InputActionGroup inputActionGroup = new()
|
||||
protected static InputActionGroup inputActionGroup = new()
|
||||
{
|
||||
allowGlobalActivation = false
|
||||
allowGlobalActivation = false,
|
||||
Source = nameof(UIToolKitPanel)
|
||||
};
|
||||
public bool IsAnimate => isAnimate;
|
||||
public bool IsValid => cancellationToken.IsCancellationRequested is false;
|
||||
public string Index { get; private set; }
|
||||
public string Index { get; private set; }
|
||||
public bool AllowCursor => allowCursor;
|
||||
public bool AllowInput => allowInput;
|
||||
protected CancellationToken cancellationToken { get; private set; }
|
||||
@@ -60,6 +72,7 @@ namespace BITKit.UX
|
||||
}
|
||||
protected virtual void Start()
|
||||
{
|
||||
BITKit.UX.UXUtils.Inject(this);
|
||||
if(IsValid && autoEntry)
|
||||
UXService.Entry(this);
|
||||
}
|
||||
@@ -71,13 +84,15 @@ namespace BITKit.UX
|
||||
|
||||
protected virtual void OnEnable()=>UXService.Register(this);
|
||||
protected virtual void OnDisable()=>UXService.UnRegister(this);
|
||||
protected virtual void OnPanelEntry(){}
|
||||
protected virtual void OnPanelExit(){}
|
||||
void IEntryElement.Entry()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
CurrentOpacity = 0;
|
||||
TargetOpacity = 1;
|
||||
OnEntryOrExit(true);
|
||||
document.rootVisualElement.SetActive(true);
|
||||
OnEntry?.Invoke();
|
||||
}
|
||||
@@ -97,15 +112,16 @@ namespace BITKit.UX
|
||||
}
|
||||
void IEntryElement.Entered()
|
||||
{
|
||||
inputActionGroup.allowInput.AddElement(this);
|
||||
//inputActionGroup.allowInput.AddElement(this);
|
||||
OnPanelEntry();
|
||||
}
|
||||
|
||||
void IEntryElement.Exit()
|
||||
{
|
||||
if (IsValid is false) return;
|
||||
TargetOpacity = 0;
|
||||
OnEntryOrExit(false);
|
||||
inputActionGroup.allowInput.RemoveElement(this);
|
||||
//inputActionGroup.allowInput.RemoveElement(this);
|
||||
OnPanelExit();
|
||||
}
|
||||
async UniTask IEntryElement.ExitAsync()
|
||||
{
|
||||
@@ -124,10 +140,6 @@ namespace BITKit.UX
|
||||
|
||||
public event Action OnEntry;
|
||||
public event Action OnExit;
|
||||
|
||||
protected virtual void OnEntryOrExit(bool isEntry)
|
||||
{
|
||||
}
|
||||
public virtual void OnUpdate(float deltaTime)
|
||||
{
|
||||
var duration = 1f;
|
||||
|
@@ -90,8 +90,6 @@ namespace BITKit.UX
|
||||
private void Awake()
|
||||
{
|
||||
DI.Register<IUXService>(this);
|
||||
|
||||
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
|
Reference in New Issue
Block a user