Example #1
0
        //加载指定名称的UI窗体
        //根据UI窗体名称加载prefabs
        //根据不同prefab加载到对应的'根窗体'的不同的节点
        //隐藏刚创建的UIprefab
        //将prefab加入到ui窗体的缓存集合中
        private BaseUIForm LoadUIForm(string uiFormName)
        {
            string     strUIFormPaths   = null; //UI窗体路径
            GameObject goCloneUIPrefabs = null; //创建的UIPrefab
            BaseUIForm baseUIForm       = null; //窗体基类


            //根据UI窗体名称获取加载路径
            _DicFormsPaths.TryGetValue(uiFormName, out strUIFormPaths);

            //根据UI窗体名称加载prefab
            if (!string.IsNullOrEmpty(strUIFormPaths))
            {
                goCloneUIPrefabs = ResourcesMgr.GetInstance().LoadAsset(strUIFormPaths, false);
            }

            //设置UIprefab父节点
            if (_TraCanvasTrasfrom != null && goCloneUIPrefabs != null)
            {
                baseUIForm = goCloneUIPrefabs.GetComponent <BaseUIForm>();
                if (baseUIForm == null)
                {
                    Debug.Log("baseUIForm is null,确认窗体预设对象上是否加载了baseUIForm的子类脚本:参数:uiFormName = " + uiFormName);
                    return(null);
                }
                switch (baseUIForm.CurrentUIType.UIForms_Type)
                {
                case UIFormType.Normal:
                    goCloneUIPrefabs.transform.SetParent(_TraNormal, false);
                    break;

                case UIFormType.Fixed:
                    goCloneUIPrefabs.transform.SetParent(_TraFixed, false);
                    break;

                case UIFormType.PopUp:
                    goCloneUIPrefabs.transform.SetParent(_TraPopUp, false);
                    break;

                default:
                    break;
                }

                goCloneUIPrefabs.SetActive(false);

                //将prefab加入到ui窗体缓存集合中
                _DicAllUIForms.Add(uiFormName, baseUIForm);

                //return baseUIForm;
            }
            else
            {
                Debug.Log("_TraCanvasTrasform or goCloneUIPrefabs is null");
                return(null);
            }

            //return null
            return(baseUIForm);
        }
Example #2
0
 //初始化加载Canvas
 private void InitRootCanvasLoading()
 {
     //Resources.Load(SysDefine.SYS_PATH_CANVAS);
     ResourcesMgr.GetInstance().LoadAsset(SysDefine.SYS_PATH_CANVAS, false);
 }