| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- using AppUI.Localization;
- using AppUI.Manager.View;
- using AppUI.View.Component;
- using SmartBowSDK;
- using UnityEngine;
- using UnityEngine.Events;
- namespace AppUI.Manager
- {
- /// <summary>
- /// 参考 <see cref="PopupMgr"/>:全局入口单例,按需创建常驻节点并统一从 Resources 弹出 <see cref="ModuleView"/>。
- /// </summary>
- public class ModuleViewMgr : MonoBehaviour
- {
- static ModuleViewMgr _ins;
- public static ModuleViewMgr ins
- {
- get
- {
- if (_ins == null)
- {
- var go = new GameObject("ModuleViewMgr");
- DontDestroyOnLoad(go);
- _ins = go.AddComponent<ModuleViewMgr>();
- }
- return _ins;
- }
- }
- void OnDestroy()
- {
- if (_ins == this)
- _ins = null;
- }
- /// <summary>弹出对话框;在返回后设置各字段,本帧结束前会执行 <see cref="ModuleView.Start"/>。</summary>
- public void Show( string bodyText, UnityAction onAgree = null, bool dontDestroyOnLoad = false)
- {
- ModuleView m = ModuleView.Show();
- if (dontDestroyOnLoad)
- DontDestroyOnLoad(m.gameObject);
- m.text = bodyText;
- m.onAgree = onAgree;
- }
- /// <summary>正文使用多语言 key(走 <see cref="AppUILocalization"/>)。</summary>
- public ModuleView ShowLocalized(
- string bodyTextKey,
- object[] formatArgs,
- UnityAction onAgree = null,
- bool dontDestroyOnLoad = false)
- {
- ModuleView m = ModuleView.Show();
- if (dontDestroyOnLoad)
- DontDestroyOnLoad(m.gameObject);
- m.textKey = bodyTextKey;
- m.textFormatArgs = formatArgs ?? new object[] { };
- m.onAgree = onAgree;
- return m;
- }
- /// <summary>弹出侧滑面板(<see cref="ModuleSideSlip"/>)。</summary>
- public ModuleSideSlip ShowSideSlip(bool dontDestroyOnLoad = false, AimDeviceType? guideDeviceType = null)
- {
- return ModuleSideSlip.Show(dontDestroyOnLoad, guideDeviceType);
- }
- public ModuleViewHorizontal ShowDeviceConnectInfrared(bool dontDestroyOnLoad = false)
- {
- ModuleViewHorizontal m = ModuleViewHorizontal.Show();
- if (dontDestroyOnLoad)
- DontDestroyOnLoad(m.gameObject);
- m.text = AppUILocalization.GetTextByKey("appui-home-tip-infrared-required");
- m.onRejectTextKey = "appui-common-cancel";
- m.onAgreeTextKey = "appui-module-confirm";
- return m;
- }
- public ModuleViewHorizontal ShowDeviceConnect(bool dontDestroyOnLoad = false)
- {
- ModuleViewHorizontal m = ModuleViewHorizontal.Show();
- if (dontDestroyOnLoad)
- DontDestroyOnLoad(m.gameObject);
- m.text = AppUILocalization.GetTextByKey("appui-module-device-not-connect");
- m.onAgree = () => {
- ViewManager.ShowView(UIViewType.DeviceView);
- };
- //m.onAgree = onAgree;
- //m.onReject = onReject;
- m.onRejectTextKey = "appui-common-cancel";
- m.onAgreeTextKey = "appui-common-connect";
- return m;
- }
- public ModuleViewHorizontal ShowPositioning(bool dontDestroyOnLoad = false)
- {
- ModuleViewHorizontal m = ModuleViewHorizontal.Show();
- if (dontDestroyOnLoad)
- DontDestroyOnLoad(m.gameObject);
- m.text = AppUILocalization.GetTextByKey("appui-module-positioning-text");
- m.onAgree = () => {
- ViewManager.ShowView(UIViewType.InfraredView);
- };
- //m.onReject = onReject;
- m.onRejectTextKey = "appui-common-cancel";
- m.onAgreeTextKey = "appui-module-positioning";
- return m;
- }
- public ModuleViewHorizontal ShowResetScreenPositioning(bool dontDestroyOnLoad = false)
- {
- ModuleViewHorizontal m = ModuleViewHorizontal.Show();
- if (dontDestroyOnLoad)
- DontDestroyOnLoad(m.gameObject);
- m.text = AppUILocalization.GetTextByKey("appui-module-positioning-reset-text");
- m.onAgree = ()=> {
- ViewManager.ShowView(UIViewType.InfraredView);
- };
- //m.onReject = onReject;
- m.onRejectTextKey = "appui-common-cancel";
- m.onAgreeTextKey = "appui-module-confirm";
- return m;
- }
- }
- }
|