You've already forked CC-Framework.BriskGameServer
Release Brisk SDK v0.4.1
This commit is contained in:
@@ -112,6 +112,8 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
private GUIStyle _statusStyle;
|
||||
private GUIStyle _listButtonStyle;
|
||||
private GUIStyle _modalStyle;
|
||||
private PropertyInfo _defaultDialogVisibleProperty;
|
||||
private MethodInfo _defaultDialogRenderMethod;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@@ -142,6 +144,12 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
if (ShouldRouteInputToDefaultDialog())
|
||||
{
|
||||
RenderDefaultErrorDialogTopmost();
|
||||
return;
|
||||
}
|
||||
|
||||
EnsureStyles();
|
||||
|
||||
var scale = Mathf.Min(Screen.width / DesignWidth, Screen.height / DesignHeight);
|
||||
@@ -167,6 +175,54 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
}
|
||||
|
||||
GUI.matrix = previousMatrix;
|
||||
|
||||
RenderDefaultErrorDialogTopmost();
|
||||
}
|
||||
|
||||
private bool ShouldRouteInputToDefaultDialog()
|
||||
{
|
||||
if (!IsDefaultErrorDialogVisible() || Event.current == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (Event.current.type)
|
||||
{
|
||||
case EventType.Layout:
|
||||
case EventType.Repaint:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsDefaultErrorDialogVisible()
|
||||
{
|
||||
EnsureDefaultDialogReflection();
|
||||
return _defaultDialogVisibleProperty != null && (bool)_defaultDialogVisibleProperty.GetValue(null, null);
|
||||
}
|
||||
|
||||
private void RenderDefaultErrorDialogTopmost()
|
||||
{
|
||||
EnsureDefaultDialogReflection();
|
||||
_defaultDialogRenderMethod?.Invoke(null, null);
|
||||
}
|
||||
|
||||
private void EnsureDefaultDialogReflection()
|
||||
{
|
||||
if (_defaultDialogVisibleProperty != null && _defaultDialogRenderMethod != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var dialogType = typeof(Brisk).Assembly.GetType("BriskDefaultErrorDialog");
|
||||
if (dialogType == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_defaultDialogVisibleProperty = dialogType.GetProperty("IsVisible", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
_defaultDialogRenderMethod = dialogType.GetMethod("RenderTopmostLegacyOverlay", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
}
|
||||
|
||||
private void DrawCurrentPage()
|
||||
@@ -219,6 +275,19 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
GUILayout.Label("失败会停留在当前页,并把错误展示在底部状态栏。", _bodyStyle);
|
||||
});
|
||||
|
||||
DrawCard("默认弹窗外观预览", () =>
|
||||
{
|
||||
GUILayout.Label("这些按钮只展示 SDK 默认弹窗外观,不会修改登录状态,也不会请求服务器。", _bodyStyle);
|
||||
DrawInlineButtons(
|
||||
new ButtonSpec("登录过期", PreviewAuthExpiredDialogAsync, false, true),
|
||||
new ButtonSpec("缺少 Token", PreviewMissingTokenDialogAsync, false, true));
|
||||
GUILayout.Space(8f);
|
||||
DrawInlineButtons(
|
||||
new ButtonSpec("服务维护", PreviewMaintenanceDialogAsync, false, true),
|
||||
new ButtonSpec("账号受限", PreviewAccountBannedDialogAsync, false, true),
|
||||
new ButtonSpec("需要更新", PreviewUpdateRequiredDialogAsync, false, true));
|
||||
});
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.EndScrollView();
|
||||
GUILayout.EndArea();
|
||||
@@ -563,6 +632,36 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
_page = SamplePage.Home;
|
||||
}
|
||||
|
||||
private Task PreviewAuthExpiredDialogAsync()
|
||||
{
|
||||
BriskDefaultErrorPresenter.Instance.ShowAuthExpired(new BriskAuthExpiredException("invalid token"));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task PreviewMissingTokenDialogAsync()
|
||||
{
|
||||
BriskDefaultErrorPresenter.Instance.ShowAuthExpired(new BriskAuthExpiredException("Missing access token."));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task PreviewMaintenanceDialogAsync()
|
||||
{
|
||||
BriskDefaultErrorPresenter.Instance.ShowBlockingError(new BriskMaintenanceException("maintenance"));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task PreviewAccountBannedDialogAsync()
|
||||
{
|
||||
BriskDefaultErrorPresenter.Instance.ShowBlockingError(new BriskAccountBannedException("account banned"));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task PreviewUpdateRequiredDialogAsync()
|
||||
{
|
||||
BriskDefaultErrorPresenter.Instance.ShowBlockingError(new BriskClientUpdateRequiredException("client update required"));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task RefreshHomeAsync()
|
||||
{
|
||||
_me = await Brisk.Player.GetMeAsync();
|
||||
|
||||
Reference in New Issue
Block a user