예제 #1
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;
        }
예제 #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;
        }
예제 #3
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());
     }
 }
예제 #4
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);
        }
예제 #5
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());
     }
 }
예제 #6
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);
        }