using AppUI.Localization; using AppUI.Manager.View; using AppUI.View.Component; using SmartBowSDK; using UnityEngine; using UnityEngine.Events; namespace AppUI.Manager { /// /// 参考 :全局入口单例,按需创建常驻节点并统一从 Resources 弹出 。 /// 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(); } return _ins; } } void OnDestroy() { if (_ins == this) _ins = null; } /// 弹出对话框;在返回后设置各字段,本帧结束前会执行 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; } /// 正文使用多语言 key(走 )。 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; } /// 弹出侧滑面板()。 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; } } }