Ejemplo n.º 1
0
        //返回本脚本实例
        public static ResouerMgr GetInstance()
        {
            if (_instance == null)
            {
                _instance = new GameObject("_Resourse").AddComponent <ResouerMgr>();
            }

            return(_instance);
        }
Ejemplo n.º 2
0
//--------------------------------------------------------------------------------------


        /// <summary>
        /// 根据窗体名称加载窗体,并将其保存到‘所有窗体集合’的字典中。
        /// 实例化到场景的窗体,会根据窗体类型自动挑选父结点
        /// </summary>
        /// <param name="UIFormName">窗体名称</param>
        /// <returns></returns>
        private BaseUIForms LoadUIForm(string UIFormName)
        {
            //路径名称
            string UIFormPath = null;

            //实例化到场景的窗体
            GameObject goClone = null;

            //窗体上挂载的BaseUiForms组件
            BaseUIForms baseUiForms = null;

            //检查有没有与窗体名称匹配的路径
            _dicPath.TryGetValue(UIFormName, out UIFormPath);

            goClone     = ResouerMgr.GetInstance().LoadAsset(UIFormPath, true);
            baseUiForms = goClone.GetComponent <BaseUIForms>();

            //根据窗体类型选择父结点
            if (_transCanvas != null && baseUiForms != null)
            {
                switch (baseUiForms.UiType.m_UIFormType)
                {
                case UIFormType.Normal:
                    UnityHelper.SetParent(_transNormal, goClone.transform);
                    // goClone.transform.SetParent(_transNormal);
                    break;

                case UIFormType.Fixed:
                    UnityHelper.SetParent(_transFixed, goClone.transform);
                    //goClone.transform.SetParent(_transFixed);
                    break;

                case UIFormType.PopUp:
                    UnityHelper.SetParent(_transPopUp, goClone.transform);
                    // goClone.transform.SetParent(_transPopUp);
                    break;

                default:
                    break;
                }
            }

            //先设置为不可见,世界空间型窗体除外
            if (baseUiForms.UiType.m_UIFormType != UIFormType.Space)
            {
                goClone.SetActive(false);
            }

            //保存到‘所有窗体集合’
            _dicAllUIForms.Add(UIFormName, baseUiForms);

            return(baseUiForms);
        }//LoadUIForm_End
Ejemplo n.º 3
0
 private Transform InitLoadCanvas()
 {
     return(ResouerMgr.GetInstance().LoadAsset("Canvas", false).transform);
 }