Ejemplo n.º 1
0
        /// <summary>
        /// 加载单个assetbundle根据名字
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private AssetBundle LoadAssetBundle(string name)
        {
            AssetBundleItem item = null;
            uint            crc  = CRC32.GetCRC32(name);

            if (!m_AssetBundleItemDic.TryGetValue(crc, out item))
            {
                AssetBundle assetBundle = null;
                string      fullPath    = ABLoadPath + name;
                assetBundle = AssetBundle.LoadFromFile(fullPath);
                if (assetBundle == null)
                {
                    ZLogger.Error(" load assetbundle Error : {0}", fullPath);
                }

                item             = m_AssetBundleItemPool.Spawn(true);
                item.assetBundle = assetBundle;
                item.RefCount++;
                m_AssetBundleItemDic.Add(crc, item);
            }
            else
            {
                item.RefCount++;
            }
            return(item.assetBundle);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 资源加载完成回调
        /// </summary>
        /// <param name="path"></param>
        /// <param name="resObj"></param>
        /// <param name="param1"></param>
        /// <param name="param2"></param>
        /// <param name="param3"></param>
        void OnLoadResourceObjFinish(string path, ResourceObj resObj, object param1 = null, object param2 = null, object param3 = null)
        {
            if (resObj == null)
            {
                return;
            }
            if (resObj.m_ResItem.m_Obj == null)
            {
                ZLogger.Error("异步加载的资源为空:{0}", path);
            }
            else
            {
                resObj.m_CloneObj = GameObject.Instantiate(resObj.m_ResItem.m_Obj) as GameObject;
            }
            //加载完成就从正在加载的异步中移除
            if (m_AsyncResObjDic.ContainsKey(resObj.m_Guid))
            {
                m_AsyncResObjDic.Remove(resObj.m_Guid);
            }

            if (resObj.m_CloneObj != null && resObj.m_SetSceneParent)
            {
                resObj.m_CloneObj.transform.SetParent(SceneTrs, false);
            }

            if (resObj.m_DealFinish != null)
            {
                int tempGuid = resObj.m_CloneObj.GetInstanceID();
                if (!m_ResourceObjDic.ContainsKey(tempGuid))
                {
                    m_ResourceObjDic.Add(tempGuid, resObj);
                }
                resObj.m_DealFinish(path, resObj.m_CloneObj, resObj.m_Param1, resObj.m_Param2, resObj.m_Param3);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 缓存加载的资源
        /// </summary>
        void CacheResource(string path, ref ResourceItem item, uint crc, Object obj, int addrefcount = 1)
        {
            if (m_NoRefrenceAssetMapList.Find(item))
            {
                m_NoRefrenceAssetMapList.Remove(item);
            }

            //缓存太多,清除最早没有使用的资源
            WashOut();

            if (item == null)
            {
                ZLogger.Error("ResourceItem is null, path : {0}", path);
            }
            if (obj == null)
            {
                ZLogger.Error("ResourceLoad Fail : {0}", path);
            }
            item.m_Obj         = obj;
            item.m_Guid        = obj.GetInstanceID();
            item.m_LastUseTime = Time.realtimeSinceStartup;
            item.RefCount     += addrefcount;
            ResourceItem oldItem = null;

            if (AssetDic.TryGetValue(item.m_Crc, out oldItem))
            {
                AssetDic[item.m_Crc] = item;
            }
            else
            {
                AssetDic.Add(item.m_Crc, item);
            }
        }
Ejemplo n.º 4
0
        void OnSetLoadFinish(string path, Object obj, object param1 = null, object param2 = null, object param3 = null)
        {
            uint       tempCrc = CRC32.GetCRC32(path);
            USpriteObj tempUSpriteObj;

            tempUSpriteObj       = USpriteClassPool.Spawn(true);
            tempUSpriteObj.m_Obj = obj as GameObject;
            tempUSpriteObj.m_Obj.transform.SetParent(USpriteRecyclePoolTrs);
            tempUSpriteObj.m_SpriteList = tempUSpriteObj.m_Obj.GetComponent <AssetList>();
            for (int i = 1, n = tempUSpriteObj.m_SpriteList.list.Count; i < n; i++)
            {
                Texture2D tempTexture = tempUSpriteObj.m_SpriteList.list[i] as Texture2D;
                tempUSpriteObj.m_SpriteDic.Add(tempTexture.name, tempUSpriteObj.m_SpriteList.list[i]);
            }
            USpriteAssetDic.Add(tempCrc, tempUSpriteObj);

            List <USpriteAsyncObj> tempUSpriteAsyncList;

            if (!USpriteAsyncDic.TryGetValue(tempCrc, out tempUSpriteAsyncList) && tempUSpriteAsyncList == null)
            {
                ZLogger.Error("USpriteMgr中,设置界面USprite出错,{0}", path);
                return;
            }
            foreach (USpriteAsyncObj tempUSpriteAsyncObj in tempUSpriteAsyncList)
            {
                for (int i = 0, n = tempUSpriteAsyncObj.m_ObjList.Count; i < n; i++)
                {
                    SetSprite(path, tempUSpriteAsyncObj.m_IconName, tempUSpriteAsyncObj.m_ObjList[i]);
                }
                tempUSpriteAsyncObj.Reset();
                USpriteAsyncObjClassPool.Recycle(tempUSpriteAsyncObj);
            }
            tempUSpriteAsyncList.Clear();
            USpriteAssetDic.Remove(tempCrc);
        }
Ejemplo n.º 5
0
        static public Component AddMissingComponent(GameObject go, string typeName)
        {
#if UNITY_5 || UNITY_2017
            Component comp = go.GetComponent(typeName);
            if (comp == null)
            {
                Type t = GetTypeFromAssembly(typeName);
                if (t != null)
                {
                    comp = go.AddComponent(t);
                }
                else
                {
                    ZLogger.Error("AddMissingComponent  {0}  can't find type", typeName);
                    return(null);
                }
            }
            return(comp);
#else
            Component comp = go.GetComponent(typeName);
            if (comp == null)
            {
                comp = go.AddComponent(typeName);
            }
            return(comp);
#endif
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 不需要实例化的资源的卸载,根据对象
        /// </summary>
        public bool ReleaseResource(Object obj, bool destoryObj = false)
        {
            if (obj == null)
            {
                return(false);
            }

            ResourceItem item = null;

            foreach (ResourceItem res in AssetDic.Values)
            {
                if (res.m_Guid == obj.GetInstanceID())
                {
                    item = res;
                }
            }

            if (item == null)
            {
                ZLogger.Error("AssetDic里不存在该资源:{0} ,可能释放了多次", obj.name);
                return(false);
            }
            item.RefCount--;
            DestoryResourceItem(item, destoryObj);
            return(true);
        }
Ejemplo n.º 7
0
        // msgId 0 表示使用Get, 1 表示使用Post
        // param 必需规则为:["key", "value", "key", "value", ...]
        public void HttpRequestLua(int canType, string canUrl, object[] param, LuaFunction canCallBack)
        {
            m_WebCallBackLua = canCallBack;
            Dictionary <string, string> tempDic = new Dictionary <string, string>();

            if (param != null)
            {
                if (param.Length % 2 != 0)
                {
                    ZLogger.Error("[NetMgr]参数规则有误!");
                    return;
                }

                for (int i = 0; i < param.Length; i = i + 2)
                {
                    tempDic.Add(param[i].ToString(), param[i + 1].ToString());
                }
            }
            if (canType == 0)
            {
                string tempStr = string.Concat(WEB_GET_COR_PRE, web_Get_Cor_Post);
                CoroutineMgr.Instance.StartCoroutine(tempStr, WebGetCor(canUrl, tempDic));
                web_Get_Cor_Post++;
            }
            else
            {
                string tempStr = string.Concat(WEB_POST_COR_PRE, web_Post_Cor_Post);
                CoroutineMgr.Instance.StartCoroutine(tempStr, WebPostCor(canUrl, tempDic));
                web_Post_Cor_Post++;
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// 获取子页面实例列
 /// </summary>
 public InterfaceView GetSubView(int index)
 {
     if (index > subViewList.Count - 1)
     {
         ZLogger.Error("获取的子界面index:{0} 不存在", index);
     }
     return(subViewList[index]);
 }
Ejemplo n.º 9
0
        public void LoadRemoteInfo(string upgradeUrl)
        {
            WebNomal oWebNormal = new WebNomal();

            try
            {
                string          json = oWebNormal.HttpGet(Settings.RemoteUrl, string.Empty);
                VersionDataCtrl list = JsonUtility.Decode <VersionDataCtrl>(json);
                if (list != null && list.VersionDatas != null && list.VersionDatas.Length > 0)
                {
                    VersionData[] oDatas = list.VersionDatas;
                    if (oDatas.Length == 0)
                    {
                        LogMessage(MESSAGE_NORMALINFO, "服务器版本信息为空,请与管理员联系!程序将在稍后启动.");
                        CallProgram();
                    }
                    else
                    {
                        for (int i = oDatas.Length - 1; i >= 0; i--)
                        {
                            VersionData oData = oDatas[i];
                            if (ThisVersion.Compare(oData.Version) == -1)
                            {
                                InteralVersions.Add(oData);
                            }
                            else
                            {
                                break;
                            }
                        }
                        NewVersion = new Version(oDatas[oDatas.Length - 1].Version);
                        LogMessage(MESSAGE_NEWVERSION, NewVersion.ToString());
                    }
                    if (InteralVersions.Count == 0)
                    {
                        LogMessage(MESSAGE_NORMALINFO, "当前版本已经是最新版本!");
                        CallProgram();
                    }
                    else
                    {
                        LoadRemoteAsset();
                    }
                }
                else
                {
                    LogMessage(MESSAGE_NORMALINFO, "服务器版本信息无法处理,请与管理员联系!程序将在稍后启动.");
                    CallProgram();
                }
            }
            catch (Exception e)
            {
                ZLogger.Error(e.Message);
                LogMessage(MESSAGE_NORMALINFO, "服务器版本信息无法处理,请检查网络或与管理员联系!程序将在稍后启动.");
                CallProgram();
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 显示下标为Index的子页面,关闭其他子页面
 /// </summary>
 public void ShowSubView(int index)
 {
     if (index > subViewList.Count - 1)
     {
         ZLogger.Error("显示的子界面index:{0} 不存在", index);
     }
     for (int i = 0; i < subViewList.Count - 1; i++)
     {
         subViewList[i]._ShowSubView(index == i);
     }
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 设置下标为index的子界面开启或关闭
 /// </summary>
 public void ActiveSubView(int index, bool activeBoo)
 {
     if (index > subViewList.Count - 1)
     {
         ZLogger.Error("获取的子界面index:{0} 不存在", index);
     }
     if (subViewList[index] != null)
     {
         subViewList[index]._ShowSubView(activeBoo);
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 场景资源卸载,根据CRC,针对SceneMgr
        /// </summary>
        public bool ReleaseResourceScene(uint crc)
        {
            ResourceItem item = null;

            if (!SceneAssetDic.TryGetValue(crc, out item) || item == null)
            {
                ZLogger.Error("AssetDic里不存在该资源:{0} ,可能释放了多次", crc);
            }
            item.RefCount--;
            DestoryResourceItemScene(item, true);
            return(true);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 打开界面,根据界面ID
        /// </summary>
        public void OpenView <T>(int viewId, int subIndex = 1, int arg1 = -1, int arg2 = -1, int arg3 = -1, string arg4 = null, string arg5 = null, string arg6 = null) where T : new()
        {
            UiExcel tempData = DataMgr.Instance.tableUI.GetInfoById(viewId);

            if (tempData != null)
            {
                _OpenViewByVo <T>(tempData, subIndex, arg1, arg2, arg3, arg4, arg5, arg6);
            }
            else
            {
                ZLogger.Error("ui表数据不存在 {0}", viewId);
            }
        }
Ejemplo n.º 14
0
        private InterfaceView _CreateView <T>(UiExcel uiData) where T : new()
        {
            InterfaceView tempView = _NewViewByName <T>(uiData);

            if (tempView == null)
            {
                ZLogger.Error("UIManager:_CreateView 创建UI失败:{0}", uiData.name);
                return(null);
            }

            tempView.updateViewState = _ViewStateChange;
            WaitOpenViewList.Add(tempView);
            return(tempView);
        }
Ejemplo n.º 15
0
        IEnumerator SceneLoadAsyncCor()
        {
            while (true)
            {
                if (!switchAsyncBoo)
                {
                    yield return(null);
                }
                else
                {
                    if (switchSceneID != 0)
                    {
                        EventMgr.Instance.TriggerEvent(SceneConst.SWITCH_SCENE_STAR_LOAD);
                        yield return(null);

                        AsyncOperation op = SceneManager.LoadSceneAsync(switchSceneID);
                        while (!op.isDone)
                        {
                            EventMgr.Instance.TriggerEvent <string, int>(SceneConst.SWITCH_SCENE_PROGRESS, "开始加载场景", (int)(op.progress * 65) + 15);
                            yield return(null);
                        }
                        if (op.isDone)
                        {
                            CacheSceneList(switchSceneID, false);

                            LoadMapConfig();
                            EventMgr.Instance.TriggerEvent <string, int>(SceneConst.SWITCH_SCENE_PROGRESS, "开始加载场景", 85);
                            yield return(null);

                            EventMgr.Instance.TriggerEvent(SceneConst.SWITCH_SCENE_LOAD_COMPLETE);

                            switchAsyncBoo = false;
                            curSceneID     = switchSceneID;
                            curMapID       = switchMapID;
                            switchSceneID  = 0;
                            switchMapID    = 0;

                            if (UIMgr.Instance.GetViewIsOpenByName("LoadingView"))
                            {
                                UIMgr.Instance.CloseViewByName("LoadingView");
                            }
                        }
                    }
                    else
                    {
                        ZLogger.Error("SceneMgr switch scene error:{0}", switchSceneID);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private void _AddSubView(InterfaceView viewClsCan)
        {
            var iter = subViewList.GetEnumerator();

            while (iter.MoveNext())
            {
                if (iter.Current == viewClsCan)
                {
                    ZLogger.Error("子界面类已经添加过,子界面名字:{0}", viewClsCan.selfGo.name);
                    return;
                }
            }
            subViewList.Add(viewClsCan);
        }
Ejemplo n.º 17
0
        private void _CloseViewByVo(UiExcel uiDataCan)
        {
            if (uiDataCan == null)
            {
                ZLogger.Error("找不到界面信息,请检查UIExcel表是否配置正确!");
                return;
            }

            InterfaceView tempView = _TryToGetOpenViewAndType(uiDataCan);

            if (tempView != null)
            {
                tempView.Close(false);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 打开悬浮界面(点击其他地方关闭)
        /// </summary>
        public void OpenPopView <T>(string viewName, int subIndex = 1, int arg1 = -1, int arg2 = -1, int arg3 = -1, string arg4 = null, string arg5 = null, string arg6 = null) where T : new()
        {
            int tempKey;

            if (_PopViewNameDic.TryGetValue(viewName, out tempKey))
            {
                _PopViewNameDic.Add(viewName, 2);
                _FrameCounter             = 0;
                _NeedCheckPopViewStateBoo = true;
                OpenView <T>(viewName, subIndex, arg1, arg2, arg3, arg4, arg5, arg6);
            }
            else
            {
                ZLogger.Error("重复打开popview viewname {0}", viewName);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 添加子页面,并返回子页面实例
        /// </summary>
        public void AddSubView <T>(String viewName, GameObject subGo) where T : new()
        {
            InterfaceView tempView = null;

            if (UIClassHelper.Instance.UIClassList.Contains(viewName))
            {
                tempView = new T() as InterfaceView;
                tempView.Ctor();
                _AddSubView(tempView);
                tempView.BindGo(subGo, this);
            }
            else
            {
                ZLogger.Error("该界面类不存在于UIClassHelper中,请检查,类名:{0}", viewName);
            }
        }
Ejemplo n.º 20
0
        //委托,在每个界面发生状态变化时候需要做的操作
        private void _ViewStateChange(InterfaceView viewCan, UIMgr.ViewStateType type)
        {
            List <UiExcel> tempUiExcelList = DataMgr.Instance.tableUI.GetInfoByNameAndValue("name", viewCan.ViewName());

            if (tempUiExcelList.Count < 1)
            {
                ZLogger.Error("找不到界面的信息,请查看UIExcel表配置是否正确!");
                return;
            }
            UiExcel uiData = tempUiExcelList[0];

            switch (type)
            {
            case ViewStateType.CLOSE:
                UpdateErrorViewDic.Remove(viewCan.ViewName());
                _UpdateCacheView(uiData.id, viewCan, false, uiData.holdBoo);
                _AdjustMaskAndActive();
                break;

            case ViewStateType.LOAD_COMPLETE:
                break;

            case ViewStateType.UNLOAD:
                _UpdateDel(uiData.id, viewCan);
                break;

            case ViewStateType.LOAD_FAIL:
                _RemoveWaitOpenValue(viewCan);
                break;

            case ViewStateType.GIVE_UP_LOAD:
                ZLogger.Info("请注意:{0}放弃加载!!!,原因是:没加载完成之前,有人调用了closeview()", viewCan.ViewName());
                _RemoveWaitOpenValue(viewCan);
                break;

            case ViewStateType.OPEN:
                _RemoveWaitOpenValue(viewCan);
                _UpdateCacheView(uiData.id, viewCan, true, uiData.holdBoo);
                _CheckExclusion(uiData, viewCan);
                _SortOpeningView();
                _AdjustMaskAndActive();
                break;

            case ViewStateType.LOAD_SUCESS:
                break;
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 不需要实例化的资源的卸载,根据路径
        /// </summary>
        public bool ReleaseResource(string path, bool destoryObj = false)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            uint         crc  = CRC32.GetCRC32(path);
            ResourceItem item = null;

            if (!AssetDic.TryGetValue(crc, out item) || item == null)
            {
                ZLogger.Error("AssetDic里不存在该资源:{0} ,可能释放了多次", path);
            }
            item.RefCount--;
            DestoryResourceItem(item, destoryObj);
            return(true);
        }
Ejemplo n.º 22
0
 //失去连接或连接失败
 private void OnDisconnect(NetResultType canType, string canStr = "")
 {
     CloseSocket();//关闭Socket
     //以下是根据不同情况输出
     if (canType == NetResultType.Disconnect)
     {
         ZLogger.Info("net 正常主动断线");
     }
     else if (canType == NetResultType.ConnectTimeOut)
     {
         ZLogger.Info("net 连接服务器超时");
     }
     else if (canType == NetResultType.Exception)
     {
         ZLogger.Error("net 异常断开服务器:{0}, type:{1}", canStr, canType.ToString());
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 根据ResourceObj卸载资源,针对给ObjectPoolMgr接口
        /// </summary>
        public bool ReleaseResource(ResourceObj resObj, bool destoryObj = false)
        {
            if (resObj == null)
            {
                return(false);
            }
            ResourceItem item = null;

            if (!AssetDic.TryGetValue(resObj.m_Crc, out item) || item == null)
            {
                ZLogger.Error("AssetDic里不存在该资源:{0} ,可能释放了多次", resObj.m_CloneObj.name);
            }
            GameObject.Destroy(resObj.m_CloneObj);
            item.RefCount--;
            DestoryResourceItem(item, destoryObj);
            return(true);
        }
Ejemplo n.º 24
0
        private InterfaceView _NewViewByName <T>(UiExcel uiData) where T : new()
        {
            InterfaceView tempView;

            if (UIClassHelper.Instance.UIClassList.Contains(uiData.name))
            {
                tempView = new T() as InterfaceView;
                tempView.Ctor();
                tempView.uiPrefabPath = uiData.path;
                return(tempView);
            }
            else
            {
                ZLogger.Error("未在UIClass中定义页面类:{0}", name);
            }
            return(null);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 加载AB配置表
        /// </summary>
        /// <returns></returns>
        public void LoadAssetBundleConfig()
        {
#if UNITY_EDITOR
            if (AppConst.DebugMode)
            {
                EventMgr.Instance.TriggerEvent(ABMgrConst.AB_CONFIG_LOAD_COMPLETE);
            }
            return;
#endif
            m_ResourceItemDic.Clear();
            string      configPath = ABLoadPath + m_ABConfigABName;
            AssetBundle configAB   = AssetBundle.LoadFromFile(configPath);
            TextAsset   textAsset  = configAB.LoadAsset <TextAsset>(m_ABConfigABName);
            if (textAsset == null)
            {
                ZLogger.Error("AssetBundleConfgi is no exist");
            }

            MemoryStream      stream = new MemoryStream(textAsset.bytes);
            BinaryFormatter   bf     = new BinaryFormatter();
            AssetBundleConfig config = (AssetBundleConfig)bf.Deserialize(stream);
            stream.Close();

            for (int i = 0; i < config.ABList.Count; i++)
            {
                ABBase       abBase = config.ABList[i];
                ResourceItem item   = new ResourceItem();
                item.m_Crc                 = abBase.Crc;
                item.m_AssetName           = abBase.AssetName;
                item.m_ABName              = abBase.ABName;
                item.m_DependenAssetBundle = abBase.ABDependce;
                if (m_ResourceItemDic.ContainsKey(item.m_Crc))
                {
                    ZLogger.Error("重复的CRC : {0}  ab包名: {1}", item.m_AssetName, item.m_ABName);
                }
                else
                {
                    m_ResourceItemDic.Add(item.m_Crc, item);
                }
            }
            EventMgr.Instance.TriggerEvent(ABMgrConst.AB_CONFIG_LOAD_COMPLETE);
            return;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 缓存加载的场景资源,针对SceneMgr
        /// </summary>
        void CacheResourceScene(string path, ref ResourceItem item, uint crc, int addrefcount = 1)
        {
            if (item == null)
            {
                ZLogger.Error("ResourceItem is null, path : {0}", path);
            }
            item.m_LastUseTime = Time.realtimeSinceStartup;
            item.RefCount     += addrefcount;
            ResourceItem oldItem = null;

            if (SceneAssetDic.TryGetValue(item.m_Crc, out oldItem))
            {
                SceneAssetDic[item.m_Crc] = item;
            }
            else
            {
                SceneAssetDic.Add(item.m_Crc, item);
            }
        }
Ejemplo n.º 27
0
        //通过名字查找对象
        public static GameObject GetChildByName(string childName, GameObject parent)
        {
            if (parent == null)
            {
                ZLogger.Error("{0} parent is null", childName);
                return(null);
            }
            Transform childT = GetChildTransform(childName, parent.transform);

            if (childT != null)
            {
                return(childT.gameObject);
            }
            else
            {
                ZLogger.Error("{0} can't find {1}", parent.name, childName);
                return(null);
            }
        }
Ejemplo n.º 28
0
        // 打开界面,供内部调用
        private void _OpenViewByVo <T>(UiExcel uiData, int subIndex, int arg1 = -1, int arg2 = -1, int arg3 = -1, string arg4 = null, string arg5 = null, string arg6 = null) where T : new()
        {
            if (uiData != null)
            {
                InterfaceView tempView = _TryToGetViewAndType(uiData);
                if (tempView == null)
                {
                    tempView = _CreateView <T>(uiData);
                }
                if (tempView == null)
                {
                    ZLogger.Error("页面没有创建过,并且无法重新创建");
                    return;
                }

                tempView.SetCanvasDepth(GetOpenViewIndex(tempView.Layer()));
                tempView.Open(subIndex, arg1, arg2, arg3, arg4, arg5, arg6);
            }
        }
Ejemplo n.º 29
0
        //
        public static Component[] FindComponentsInChild(string componentTypeName, GameObject go)
        {
            if (string.IsNullOrEmpty(componentTypeName) || (go == null))
            {
                ZLogger.Error("Error params for FindComponentsInChild, componentTypeName is {0}, go is {1}", componentTypeName, go);
                return(new Component[0]);
            }
            Type t = GetTypeFromAssembly(componentTypeName);

            if (t != null)
            {
                return(go.transform.GetComponentsInChildren(t));
            }
            else
            {
                ZLogger.Error("No such type {0}", componentTypeName);
                return(new Component[0]);
            }
        }
Ejemplo n.º 30
0
        // 创建mask遮罩
        private void _CreateMask()
        {
            _maskBg = new GameObject("MaskBg");
            //Image maskBgImg = UGUITool.AddComponent(_maskBg, "UnityEngine.UI.Image") as Image;
            Image maskBgImg = _maskBg.AddComponent <Image>();

            maskBgImg.type = Image.Type.Sliced;
            _maskBgRect    = _maskBg.GetComponent <RectTransform>();
            Sprite maskSprite = USpriteMgr.Instance.GetSprite(SpriteName.CommonSprite, maskBgSpriteName);

            if (maskSprite != null)
            {
                maskBgImg.sprite = maskSprite;
            }
            else
            {
                ZLogger.Error("图集{0}中不存在资源{1},请价差UIManager中的maskBgSpriteName", SpriteName.CommonSprite, maskBgSpriteName);
            }
            maskBgImg.color = new Color(0, 0, 0, 1);
        }