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