This commit is contained in:
parent
e6bb3dc5fa
commit
c0ded1f99b
|
@ -490,7 +490,7 @@ namespace BITKit.Net
|
|||
await BITApp.SwitchToMainThread();
|
||||
if (value is Exception e)
|
||||
{
|
||||
throw e;
|
||||
throw new InGameException(e.Message,e);
|
||||
}
|
||||
if (UniTask.CompletedTask is T t)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,10 @@ namespace BITKit.UX
|
|||
/// <para>⭐基本UI导航回调</para>
|
||||
public interface IUXPanel:IEntryElement,IUpdate
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为窗口,用于覆盖其他面板
|
||||
/// </summary>
|
||||
bool IsWindow { get; }
|
||||
/// <summary>
|
||||
/// 该面板是否具有动画
|
||||
/// </summary>
|
||||
|
@ -47,7 +51,8 @@ namespace BITKit.UX
|
|||
{
|
||||
protected abstract IUXPanel service { get; }
|
||||
private IUXPanel _iuxPanelImplementation => service;
|
||||
public bool IsAnimate => _iuxPanelImplementation.IsAnimate;
|
||||
public bool IsWindow=>_iuxPanelImplementation.IsWindow;
|
||||
public bool IsAnimate => _iuxPanelImplementation.IsAnimate;
|
||||
|
||||
public bool IsValid => _iuxPanelImplementation.IsValid;
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@ namespace BITKit.UX
|
|||
}
|
||||
[Header(Constant.Header.Components)]
|
||||
[SerializeField] protected UIDocument document;
|
||||
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private bool isWindow;
|
||||
[SerializeField] private bool isAnimate;
|
||||
[SerializeField] private bool allowCursor;
|
||||
[SerializeField] private bool allowInput;
|
||||
|
@ -39,12 +41,12 @@ namespace BITKit.UX
|
|||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private Optional<float> entryDuration;
|
||||
[SerializeField] private Optional<float> exitDuration;
|
||||
|
||||
protected static InputActionGroup inputActionGroup = new()
|
||||
{
|
||||
allowGlobalActivation = false,
|
||||
Source = nameof(UIToolKitPanel)
|
||||
};
|
||||
public bool IsWindow => isWindow;
|
||||
public bool IsAnimate => isAnimate;
|
||||
public bool IsValid => cancellationToken.IsCancellationRequested is false;
|
||||
public string Index { get; private set; }
|
||||
|
@ -56,7 +58,7 @@ namespace BITKit.UX
|
|||
protected float CurrentOpacity
|
||||
{
|
||||
get => background?.GetOpacity() ?? _currentOpacity;
|
||||
set
|
||||
set
|
||||
{
|
||||
_currentOpacity = value;
|
||||
background?.SetOpacity(value);
|
||||
|
@ -69,6 +71,7 @@ namespace BITKit.UX
|
|||
Index= typeof(UIToolKitPanel) == GetType() ? gameObject.name : GetType().Name;
|
||||
document.rootVisualElement.SetActive(false);
|
||||
background?.SetOpacity(0);
|
||||
if (IsWindow) document.sortingOrder++;
|
||||
}
|
||||
protected virtual void Start()
|
||||
{
|
||||
|
@ -119,7 +122,7 @@ namespace BITKit.UX
|
|||
throw;
|
||||
}
|
||||
}
|
||||
async UniTask IEntryElement.EntryAsync()
|
||||
async UniTask IEntryElement.EntryAsync()
|
||||
{
|
||||
if (entryDuration.Allow is false) return;
|
||||
while (CurrentOpacity < 1 && TargetOpacity is 1)
|
||||
|
|
|
@ -33,7 +33,8 @@ namespace BITKit.UX
|
|||
}
|
||||
|
||||
|
||||
private static EntryGroup<IUXPanel> EntryGroup = new();
|
||||
internal static EntryGroup<IUXPanel> EntryGroup = new();
|
||||
internal static EntryGroup<IUXPanel> WindowEntryGruop = new();
|
||||
/// <summary>
|
||||
/// 内部注册面板队列
|
||||
/// </summary>
|
||||
|
@ -77,6 +78,11 @@ namespace BITKit.UX
|
|||
|
||||
public static void Return()
|
||||
{
|
||||
if(WindowEntryGruop.TryGetEntried(out var window))
|
||||
{
|
||||
WindowEntryGruop.Entry(-1);
|
||||
return;
|
||||
}
|
||||
if (History.TryPop(out var returnPanel))
|
||||
{
|
||||
ReturnBuffer.Release(returnPanel);
|
||||
|
@ -138,6 +144,12 @@ namespace BITKit.UX
|
|||
|
||||
if (EntryQueue.TryPop(out var nextPanel))
|
||||
{
|
||||
if (nextPanel.IsWindow)
|
||||
{
|
||||
WindowEntryGruop.Entry(nextPanel);
|
||||
return;
|
||||
}
|
||||
WindowEntryGruop.Entry(-1);
|
||||
History.Push(CurrentPanel);
|
||||
EntryGroup.Entry(x=>x.Index==nextPanel.Index);
|
||||
BITAppForUnity.AllowCursor.SetElements(this, nextPanel.AllowCursor);
|
||||
|
@ -148,6 +160,10 @@ namespace BITKit.UX
|
|||
{
|
||||
currentPanel.OnUpdate(Time.deltaTime);
|
||||
};
|
||||
if(WindowEntryGruop.TryGetEntried(out var windowPanel))
|
||||
{
|
||||
windowPanel.OnUpdate(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
void IUXService.Register(IUXPanel panel) => Register(panel);
|
||||
|
@ -164,32 +180,36 @@ namespace BITKit.UX
|
|||
}
|
||||
#if UNITY_EDITOR
|
||||
[CustomEditor(typeof(UXService))]
|
||||
public class UXServiceInspector:BITInspector<UXService>
|
||||
public class UXServiceInspector : BITInspector<UXService>
|
||||
{
|
||||
private Label currentPanelLabel;
|
||||
private Label currentWindow;
|
||||
private Label panelsLabel;
|
||||
private Label historyLabel;
|
||||
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
FillDefaultInspector();
|
||||
CreateSubTitle("States");
|
||||
currentPanelLabel = root.Create<Label>();
|
||||
currentWindow = root.Create<Label>();
|
||||
CreateSubTitle("Panels");
|
||||
panelsLabel = root.Create<Label>();
|
||||
CreateSubTitle("History");
|
||||
historyLabel = root.Create<Label>();
|
||||
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (panelsLabel is null || currentPanelLabel is null || historyLabel is null) return;
|
||||
panelsLabel.text=string.Join("\n",UXService.Panels);
|
||||
currentPanelLabel.text = string.Join("\n",UXService.CurrentPanel?.Index);
|
||||
historyLabel.text = string.Join("\n",UXService.History.Select(x=>x is null ? "Null" : x.Index));
|
||||
panelsLabel.text = string.Join("\n", UXService.Panels);
|
||||
currentPanelLabel.text = string.Join("\n", UXService.CurrentPanel?.Index);
|
||||
historyLabel.text = string.Join("\n", UXService.History.Select(x => x is null ? "Null" : x.Index));
|
||||
currentWindow.text = UXService.WindowEntryGruop.TryGetEntried(out var window) ? window.Index : "None";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue