Beispiel #1
0
        /// <summary>
        /// 根据UIID创建UI预设
        /// </summary>
        /// <param name="id"></param>
        public IEnumerator CreateUI(UIID id)
        {
            Debug.Log("创建UI:" + id);
            UISourceInfo uiSourceInfo;                          //获取需要的UISourceInfo

            if (DictUISource.TryGetValue(id, out uiSourceInfo)) //先从内存中获取
            {
                if (uiSourceInfo.UIObj != null)                 //如果场景中存在这个UI,则不会创建,直接显示
                {
                    //ShowUI(id);
                    yield return(null);
                }
                else
                {
                    //加载UI资源
                    yield return(StartCoroutine(SourceManager._Instance.DownloadAssetBundle(uiSourceInfo.bundleName, (bundle, dependBundles) => {
                        GameObject obj = bundle.LoadAsset <GameObject>(uiSourceInfo.sourceName);
                        uiSourceInfo.UIObj = Instantiate(obj);                                   //保存创建的对象
                        UIReset(ref uiSourceInfo.UIObj);                                         //重置transform
                        uiSourceInfo.UIObj.transform.SetSiblingIndex(uiSourceInfo.SiblingIndex); //设置深度

                        //添加需要的脚本
                        for (int i = 0; i < uiSourceInfo.scripts.Length; i++)
                        {
                            uiSourceInfo.UIObj.AddComponent(SourceManager._Instance.getType(uiSourceInfo.scripts[i]));
                        }

                        if (id != UIID.Loading) //初始化UI
                        {
                            UIParam param = new UIParam(id);
                            uiSourceInfo.UIObj.GetComponent <UIBase>().InitUI(param);
                        }
                        //UI信息重新保存到内存中
                        DictUISource[id] = uiSourceInfo;

                        //释放主资源包
                        bundle.Unload(false);
                        //释放依赖资源包
                        if (dependBundles != null)
                        {
                            for (int i = 0; i < dependBundles.Length; i++)
                            {
                                dependBundles[i].Unload(false);
                            }
                        }
                    })));
                }
            }
            else
            {
                Debug.Log("UI资源不存在,未加载成功!" + id);
            }
        }
Beispiel #2
0
        public void InitUI(UIParam param)
        {
            if (param.ID != UIID.Menu)
            {
                return;
            }

            //添加进入AR按钮的动画
            BT_Start = transform.FindChild("BT_Start").GetComponent <Button>();
            Tweener BT_StartTween = BT_Start.transform.DOScale(1.2f, 0.2f);

            BT_StartTween.Pause();
            BT_StartTween.SetLoops(2, LoopType.Yoyo);
            BT_StartTween.SetEase(Ease.InQuad);
            BT_StartTween.SetAutoKill(false);
            BT_StartTween.OnComplete(delegate()
            {
                BT_StartTween.Rewind();
                StartCoroutine(LoadingProcess._Instance.LoadBegin(
                                   UIID.Menu,
                                   LoadType.LoadOver,
                                   () =>
                {
                },
                                   (UIid) =>
                {
                    LoadingProcess._Instance.ShowInfo("无下一步操作...", 50, Color.red, 1f);
                })
                               );
            });

            BT_Start.onClick.AddListener(delegate()
            {
                BT_StartTween.PlayForward();
                SoundManager._Instacne.PlayAudio("Capture");
            });
        }