//初始化核心数据,加载“UI窗体路径”到集合中。 public void Awake() { //字段初始化 _DicALLUIForms = new Dictionary <string, BaseUIForm>(); _DicCurrentShowUIForms = new Dictionary <string, BaseUIForm>(); _StaCurrentUIForms = new Stack <BaseUIForm>(); //初始化加载(根UI窗体)Canvas预设 InitRootCanvasLoading(); //得到UI根节点、全屏节点、固定节点、弹出节点 _TraCanvasTransfrom = GameObject.FindGameObjectWithTag(SysDefine.SYS_TAG_CANVAS).transform; _TraNormal = UnityHelper.FindTheChildNode(_TraCanvasTransfrom.gameObject, SysDefine.SYS_NORMAL_NODE); _TraFixed = UnityHelper.FindTheChildNode(_TraCanvasTransfrom.gameObject, SysDefine.SYS_FIXED_NODE); _TraPopUp = UnityHelper.FindTheChildNode(_TraCanvasTransfrom.gameObject, SysDefine.SYS_POPUP_NODE); _TraUIScripts = UnityHelper.FindTheChildNode(_TraCanvasTransfrom.gameObject, SysDefine.SYS_SCRIPTMANAGER_NODE); GuideMask = UnityHelper.FindTheChildNode(_TraCanvasTransfrom.gameObject, SysDefine.GUIDE_MASK); var ca = UnityHelper.FindTheChildNode(_TraCanvasTransfrom.gameObject, "UICamera"); GlobalObj.InitUiCamera(ca.GetComponent <Camera>()); GlobalObj.InitCanvas(_TraCanvasTransfrom); GlobalObj.InitGuideMask(GuideMask); //把本脚本作为“根UI窗体”的子节点。 this.gameObject.transform.SetParent(_TraUIScripts, false); //"根UI窗体"在场景转换的时候,不允许销毁 DontDestroyOnLoad(_TraCanvasTransfrom); }