// 加载 Prefab
        protected void loadPrefab()
        {
            if (m_bNeedReload)
            {
                if (m_selfGo != null)
                {
                    UtilApi.Destroy(m_selfGo);
                    m_selfGo = null;
                }
                if (m_prefabRes != null)
                {
                    Ctx.m_instance.m_uiPrefabMgr.unload(m_prefabRes.GetPath(), null);
                    m_prefabRes = null;
                }
                m_prefabRes = Ctx.m_instance.m_uiPrefabMgr.getAndSyncLoad<UIPrefabRes>(m_prefabPath);
                m_selfGo = m_prefabRes.InstantiateObject(m_prefabPath);

                if (m_bNeedPlaceHolderGo && m_placeHolderGo != null)
                {
                    UtilApi.SetParent(m_selfGo, m_placeHolderGo, false);
                }
                else if (m_pntGo != null)
                {
                    UtilApi.SetParent(m_selfGo, m_pntGo, false);
                }

                findWidget();
                m_bImageGoChange = true;      // 设置重新更新图像
            }
            m_bNeedReload = false;
        }
Esempio n. 2
0
        // 加载 Prefab
        protected void loadPrefab()
        {
            if (m_bNeedReload)
            {
                if (m_selfGo != null)
                {
                    UtilApi.Destroy(m_selfGo);
                    m_selfGo = null;
                }
                if (m_prefabRes != null)
                {
                    Ctx.m_instance.m_uiPrefabMgr.unload(m_prefabRes.GetPath(), null);
                    m_prefabRes = null;
                }
                m_prefabRes = Ctx.m_instance.m_uiPrefabMgr.getAndSyncLoad <UIPrefabRes>(m_prefabPath);
                m_selfGo    = m_prefabRes.InstantiateObject(m_prefabPath);

                if (m_bNeedPlaceHolderGo && m_placeHolderGo != null)
                {
                    UtilApi.SetParent(m_selfGo, m_placeHolderGo, false);
                }
                else if (m_pntGo != null)
                {
                    UtilApi.SetParent(m_selfGo, m_pntGo, false);
                }

                findWidget();
                m_bImageGoChange = true;      // 设置重新更新图像
            }
            m_bNeedReload = false;
        }
Esempio n. 3
0
        // 代码资源加载完成处理
        public void onCodeloadedByRes(UIPrefabRes res)
        {
            UIFormID ID = m_UIAttrs.GetFormIDByPath(res.GetPath(), ResPathType.ePathCodePath);  // 获取 FormID

            m_ID2CodeLoadingItemDic.Remove(ID);
            addFormNoReady(m_id2FormDic[ID]);
            onCodeLoadedByForm(m_id2FormDic[ID]);
        }
Esempio n. 4
0
        // 代码资源加载处理
        public void onCodeLoadEventHandle(IDispatchObject dispObj)
        {
            UIPrefabRes res = dispObj as UIPrefabRes;

            if (res.refCountResLoadResultNotify.resLoadState.hasSuccessLoaded())
            {
                onCodeloadedByRes(res);
            }
            else if (res.refCountResLoadResultNotify.resLoadState.hasFailed())
            {
                UIFormID ID = m_UIAttrs.GetFormIDByPath(res.GetPath(), ResPathType.ePathCodePath);  // 获取 FormID
                m_ID2CodeLoadingItemDic.Remove(ID);
            }
        }
Esempio n. 5
0
        // 窗口控件资源加载处理
        public void onWidgetLoadEventHandle(IDispatchObject dispObj)
        {
            UIPrefabRes res = dispObj as UIPrefabRes;

            if (res.refCountResLoadResultNotify.resLoadState.hasSuccessLoaded())
            {
                onWidgetloadedByRes(res);
            }
            else if (res.refCountResLoadResultNotify.resLoadState.hasFailed())
            {
                UIFormID ID = m_UIAttrs.GetFormIDByPath(res.GetPath(), ResPathType.ePathComUI);  // 获取 FormID
                m_ID2WidgetLoadingItemDic.Remove(ID);
                Ctx.m_instance.m_logSys.log("UIFormID =  , Failed Prefab");
            }
        }
Esempio n. 6
0
 virtual protected void addUIAndBox()
 {
     if (m_uiPrefabRes == null)
     {
         m_uiPrefabRes = Ctx.m_instance.m_uiPrefabMgr.getAndSyncLoad <UIPrefabRes>(m_uiPrefabPath);
         GameObject _go = m_uiPrefabRes.InstantiateObject(m_uiPrefabPath);
         _go.name = "UIRoot";
         UtilApi.SetParent(_go, gameObject(), false);
     }
     if (m_boxModel == null)
     {
         m_boxModel = Ctx.m_instance.m_modelMgr.getAndSyncLoad <ModelRes>(m_boxModelPath);
         UtilApi.copyBoxCollider(m_boxModel.getObject() as GameObject, gameObject());
     }
 }
Esempio n. 7
0
        // 窗口控件资源加载完成处理
        public void onWidgetloadedByRes(UIPrefabRes res)
        {
            string   path = res.GetPath();
            UIFormID ID   = m_UIAttrs.GetFormIDByPath(path, ResPathType.ePathComUI); // 获取 FormID

            m_ID2WidgetLoadingItemDic.Remove(ID);

            UIAttrItem attrItem = m_UIAttrs.m_id2AttrDic[ID];

            m_id2FormDic[ID].bLoadWidgetRes    = true;
            m_id2FormDic[ID].m_GUIWin.m_uiRoot = res.InstantiateObject(attrItem.m_widgetPath);
            if (attrItem.m_bNeedLua)
            {
                m_id2FormDic[ID].luaCSBridgeForm.gameObject = m_id2FormDic[ID].m_GUIWin.m_uiRoot;
                m_id2FormDic[ID].luaCSBridgeForm.init();
            }

            // 设置位置
            UtilApi.SetParent(m_id2FormDic[ID].m_GUIWin.m_uiRoot.transform, m_canvasList[(int)attrItem.m_canvasID].layerList[(int)attrItem.m_LayerID].layerTrans, false);

            // 先设置再设置缩放,否则无效
            m_id2FormDic[ID].m_GUIWin.m_uiRoot.transform.SetAsLastSibling();   // 放在最后
            UtilApi.SetActive(m_id2FormDic[ID].m_GUIWin.m_uiRoot, false);      // 出发 onShow 事件
            //if (m_dicForm[ID].hideOnCreate)
            //{
            //    UtilApi.SetActive(m_dicForm[ID].m_GUIWin.m_uiRoot, false);
            //}
            if (!m_id2FormDic[ID].hideOnCreate)
            {
                showFormInternal(ID);   // 如果 onShow 中调用 exit 函数,就会清掉 m_dicForm 中的内容。如果设置了 exitMode = false,就不会清掉 m_dicForm ,就不会有问题
            }

            if (null != Ctx.m_instance.m_cbUIEvent)
            {
                if (m_id2FormDic.ContainsKey(ID))                                // 如果 onShow 中调用 exit 函数,并且没有设置 exitMode = false ,就会清除 m_dicForm, 这个时候再调用这个函数,就会有问题,是不是添加延迟卸载
                {
                    Ctx.m_instance.m_cbUIEvent.onWidgetLoaded(m_id2FormDic[ID]); // 资源加载完成
                }
            }

            // 卸载资源
            Ctx.m_instance.m_uiPrefabMgr.unload(path, onWidgetLoadEventHandle);
        }
        override public void dispose()
        {
            if (m_model != null)
            {
                m_model.dispose();
                m_model = null;
            }

            if (m_uiPrefabRes != null)
            {
                Ctx.m_instance.m_uiPrefabMgr.unload(m_uiPrefabRes.GetPath(), null);
                m_uiPrefabRes = null;
            }
            if (m_boxModel != null)
            {
                Ctx.m_instance.m_modelMgr.unload(m_boxModel.GetPath(), null);
                m_boxModel = null;
            }
        }
Esempio n. 9
0
        override public void dispose()
        {
            if (m_model != null)
            {
                m_model.dispose();
                m_model = null;
            }

            if (m_uiPrefabRes != null)
            {
                Ctx.m_instance.m_uiPrefabMgr.unload(m_uiPrefabRes.GetPath(), null);
                m_uiPrefabRes = null;
            }
            if (m_boxModel != null)
            {
                Ctx.m_instance.m_modelMgr.unload(m_boxModel.GetPath(), null);
                m_boxModel = null;
            }
        }
Esempio n. 10
0
        public void testAsyncLoadUIPrefabRefCount()
        {
            LoadParam param;

            param = Ctx.m_instance.m_poolSys.newObject <LoadParam>();
            LocalFileSys.modifyLoadParam("UI/UIChat/UIChat.prefab", param);
            param.m_loadEventHandle = onUIPrefabLoadEventHandle;
            UIPrefabRes aaa = Ctx.m_instance.m_uiPrefabMgr.getAndLoad <UIPrefabRes>(param);

            Ctx.m_instance.m_poolSys.deleteObj(param);

            Ctx.m_instance.m_uiPrefabMgr.unload(aaa.GetPath(), onUIPrefabLoadEventHandle);

            param = Ctx.m_instance.m_poolSys.newObject <LoadParam>();
            LocalFileSys.modifyLoadParam("UI/UIChat/UIChat.prefab", param);
            param.m_loadEventHandle = onUIPrefabLoadEventHandle;
            UIPrefabRes bbb = Ctx.m_instance.m_uiPrefabMgr.getAndLoad <UIPrefabRes>(param);

            Ctx.m_instance.m_poolSys.deleteObj(param);

            Ctx.m_instance.m_uiPrefabMgr.unload(bbb.GetPath(), onUIPrefabLoadEventHandle);
        }
Esempio n. 11
0
 public void testSyncLoadRefCount()
 {
     UIPrefabRes aaa = Ctx.m_instance.m_uiPrefabMgr.getAndSyncLoad <UIPrefabRes>("UI/UIChat/UIChat.prefab");
     UIPrefabRes bbb = Ctx.m_instance.m_uiPrefabMgr.getAndSyncLoad <UIPrefabRes>("UI/UIChat/UIChat.prefab");
 }
Esempio n. 12
0
 public virtual void onUIPrefabLoadEventHandle(IDispatchObject dispObj)
 {
     UIPrefabRes uiPrefab = dispObj as UIPrefabRes;
 }
Esempio n. 13
0
 virtual protected void addUIAndBox()
 {
     if (m_uiPrefabRes == null)
     {
         m_uiPrefabRes = Ctx.m_instance.m_uiPrefabMgr.getAndSyncLoad<UIPrefabRes>(m_uiPrefabPath);
         GameObject _go = m_uiPrefabRes.InstantiateObject(m_uiPrefabPath);
         _go.name = "UIRoot";
         UtilApi.SetParent(_go, gameObject(), false);
     }
     if (m_boxModel == null)
     {
         m_boxModel = Ctx.m_instance.m_modelMgr.getAndSyncLoad<ModelRes>(m_boxModelPath);
         UtilApi.copyBoxCollider(m_boxModel.getObject() as GameObject, gameObject());
     }
 }
Esempio n. 14
0
        // 窗口控件资源加载完成处理
        public void onWidgetloadedByRes(UIPrefabRes res)
        {
            string path = res.GetPath();
            UIFormID ID = m_UIAttrs.GetFormIDByPath(path, ResPathType.ePathComUI);  // 获取 FormID
            m_ID2WidgetLoadingItemDic.Remove(ID);

            UIAttrItem attrItem = m_UIAttrs.m_id2AttrDic[ID];
            m_id2FormDic[ID].bLoadWidgetRes = true;
            m_id2FormDic[ID].m_GUIWin.m_uiRoot = res.InstantiateObject(attrItem.m_widgetPath);
            if (attrItem.m_bNeedLua)
            {
                m_id2FormDic[ID].luaCSBridgeForm.gameObject = m_id2FormDic[ID].m_GUIWin.m_uiRoot;
                m_id2FormDic[ID].luaCSBridgeForm.init();
            }

            // 设置位置
            UtilApi.SetParent(m_id2FormDic[ID].m_GUIWin.m_uiRoot.transform, m_canvasList[(int)attrItem.m_canvasID].layerList[(int)attrItem.m_LayerID].layerTrans, false);

            // 先设置再设置缩放,否则无效
            m_id2FormDic[ID].m_GUIWin.m_uiRoot.transform.SetAsLastSibling();               // 放在最后
            UtilApi.SetActive(m_id2FormDic[ID].m_GUIWin.m_uiRoot, false);      // 出发 onShow 事件
            //if (m_dicForm[ID].hideOnCreate)
            //{
            //    UtilApi.SetActive(m_dicForm[ID].m_GUIWin.m_uiRoot, false);
            //}
            if (!m_id2FormDic[ID].hideOnCreate)
            {
                showFormInternal(ID);   // 如果 onShow 中调用 exit 函数,就会清掉 m_dicForm 中的内容。如果设置了 exitMode = false,就不会清掉 m_dicForm ,就不会有问题
            }

            if (null != Ctx.m_instance.m_cbUIEvent)
            {
                if (m_id2FormDic.ContainsKey(ID))      // 如果 onShow 中调用 exit 函数,并且没有设置 exitMode = false ,就会清除 m_dicForm, 这个时候再调用这个函数,就会有问题,是不是添加延迟卸载
                {
                    Ctx.m_instance.m_cbUIEvent.onWidgetLoaded(m_id2FormDic[ID]);  // 资源加载完成
                }
            }

            // 卸载资源
            Ctx.m_instance.m_uiPrefabMgr.unload(path, onWidgetLoadEventHandle);
        }
Esempio n. 15
0
 // 代码资源加载完成处理
 public void onCodeloadedByRes(UIPrefabRes res)
 {
     UIFormID ID = m_UIAttrs.GetFormIDByPath(res.GetPath(), ResPathType.ePathCodePath);  // 获取 FormID
     m_ID2CodeLoadingItemDic.Remove(ID);
     addFormNoReady(m_id2FormDic[ID]);
     onCodeLoadedByForm(m_id2FormDic[ID]);
 }