示例#1
0
 /// <summary>
 /// 同步方式;
 /// </summary>
 public IEnumerator LoadConfigSync(string strOutFilePath, string strInFilePath, string strNetFilePath, string strName)
 {
     strOutFilePath = strOutFilePath + strName + ".txt";
     strInFilePath  = strInFilePath + strName + ".txt";
     strName        = strName + ".txt";
     if (WWWDownLoaderConfig.CheckResNeedUpdate(strName))
     {
         DownLoadPack downloadPack = WWWDownLoader.InsertDownLoad(strName, strNetFilePath + strName, DownLoadAssetType.Text, null, null, DownLoadOrderType.AfterRunning);
         if (downloadPack != null)
         {
             while (!downloadPack.AssetReady)
             {
                 yield return(null);
             }
             using (StreamReader sr = new StreamReader(new MemoryStream(downloadPack.DataBytes), CommonFunc.GetCharsetEncoding()))
             {
                 ParseConfig(sr);
                 sr.Close();
             }
         }
         WWWDownLoader.RemoveDownLoad(strName, null);
     }
     else
     {
         IEnumerator itor = LoadConfigFromLocal(strOutFilePath, strInFilePath);
         while (itor.MoveNext())
         {
             yield return(null);
         }
     }
     Messenger.Broadcast(MessangerEventDef.LOAD_ONEASSET_FINISH, MessengerMode.DONT_REQUIRE_LISTENER);
 }
示例#2
0
        public static IEnumerator LoadAllShader(string assetDir, string assetWWWDir, string inAssetDir, string inAssetWWWDir, string assetNetDir)
        {
            string strName = "all.shd";

            if (WWWDownLoaderConfig.CheckResNeedUpdate(strName))
            {
                DownLoadPack downloadPack = WWWDownLoader.InsertDownLoad(strName, assetNetDir + strName, DownLoadAssetType.AssetBundle, null, null, DownLoadOrderType.AfterRunning);
                if (downloadPack != null)
                {
                    while (!downloadPack.AssetReady)
                    {
                        yield return(null);
                    }
                    m_ShaderAsset = downloadPack.Bundle;
                }
                WWWDownLoader.RemoveDownLoad(strName, null);
            }
            else
            {
                IEnumerator itor = LoadAllShader(assetDir, assetWWWDir, inAssetDir, inAssetWWWDir);
                while (itor.MoveNext())
                {
                    yield return(null);
                }
            }

            if (m_ShaderAsset != null)
            {
                m_AllShader = m_ShaderAsset.LoadAll();
            }
            Shader.WarmupAllShaders();
            Messenger.Broadcast(MessangerEventDef.LOAD_ONEASSET_FINISH, MessengerMode.DONT_REQUIRE_LISTENER);
        }
示例#3
0
        RoleBodyLoader(string strFileName, ItemCloth_Type Type, ItemCloth_Type[] excludeTypes, string childPath)         //: base(strFileName)
        {
            m_ResuceName   = strFileName;
            m_ColthType    = Type;
            m_ExcludeTypes = excludeTypes;
            m_ChildPath    = childPath;

            m_isNetLoad = WWWDownLoaderConfig.CheckResNeedUpdate(m_ResuceName);
        }
示例#4
0
        public static IEnumerator LoaddefaultSkins()
        {
            string strName = "default.skn";

            if (WWWDownLoaderConfig.CheckResNeedUpdate(strName))
            {
                DownLoadPack downloadPack = WWWDownLoader.InsertDownLoad(strName, GetSkinResPath() + strName, DownLoadAssetType.AssetBundle, null, null, DownLoadOrderType.AfterRunning);
                if (downloadPack != null)
                {
                    while (!downloadPack.AssetReady)
                    {
                        yield return(null);
                    }
                    s_DefaultSkins = downloadPack.Bundle;
                }

                WWWDownLoader.RemoveDownLoad(strName, null);
            }
            else
            {
                string strSkins  = mAssetWWWDir + "Skin/default.skn";
                string assetPath = mAssetDir + "Skin/default.skn";
                if (!File.Exists(assetPath))
                {
                    strSkins = mInAssetWWWDir + "Skin/default.skn";
                }

                WWW www = null;
                using (www = new WWW(strSkins))
                {
                    while (!www.isDone)
                    {
                        yield return(null);
                    }
                    if (www.error != null)
                    {
                        Debug.LogError("Skin Load Error!");
                        Debug.LogError(www.error);
                    }
                    else
                    {
                        s_DefaultSkins = www.assetBundle;
                    }

                    www.Dispose();
                    www = null;
                }
            }
            Messenger.Broadcast(MessangerEventDef.LOAD_ONEASSET_FINISH, MessengerMode.DONT_REQUIRE_LISTENER);
        }
示例#5
0
        static private DownLoadPack AddDownLoadAssetPack(string strName, string strURL, DownLoadAssetType assetType, Callback <object> callBack, object exData, bool debugError)
        {
            DownLoadPack gtAssetPack = null;

            if (m_AssetPackMap.ContainsKey(strName))            //如果存在上一个if的情况,此步等同于下载不销毁,重置回调 or 正常流程重复请求;
            {
                gtAssetPack = m_AssetPackMap[strName];
                if (gtAssetPack != null)
                {
                    gtAssetPack.AssetInfo.m_callBack += callBack;
                    gtAssetPack.m_AssetRefer++;
                }
            }
            else
            {
                DownLoadAssetInfo gtInfo = null;
                if (assetType == DownLoadAssetType.ConfigVersion)                //配置文件 特殊处理;
                {
                    gtInfo           = new DownLoadAssetInfo();
                    gtInfo.m_strName = strName;
                }
                else
                {
                    gtInfo = WWWDownLoaderConfig.GetAssetDownLoadInfo(strName);
                }

                if (gtInfo == null)
                {
                    Debug.LogError("WWWLoader LoadAsset, DownLoadInfo can not be null. \n" + strName);
                }
                else
                {
                    gtInfo.m_callBack   = callBack;
                    gtInfo.m_strFileUrl = strURL;                    //for组装下载路径 and 保存路径;

                    //gtAssetPack = new DownLoadPack(m_strWWWDownLoadUrl, gtInfo, assetType, DownLoadFinish, exData, debugError);
                    gtAssetPack = new DownLoadPack(m_strWWWDownLoadUrl, gtInfo, assetType, null, exData, debugError);

                    m_AssetPackMap.Add(strName, gtAssetPack);
                }
            }

            return(gtAssetPack);
        }
示例#6
0
        private IEnumerator LoadingAsset(string assetName, bool isOnlyDownLoad, DownLoadOrderType downLoadOrderType)
        {
            if (m_AllAssets.ContainsKey(assetName))
            {
                AssetPack assetPack = m_AllAssets[assetName];

                string strNetLoadName = assetName + m_strAssetExtension;
                if (WWWDownLoaderConfig.CheckResNeedUpdate(strNetLoadName))                //检查版本,区分是加载or下载;
                {
                    DownLoadPack downloadPack = WWWDownLoader.InsertDownLoad(strNetLoadName, m_strAssetNetDir + strNetLoadName, DownLoadAssetType.AssetBundle, null, null, downLoadOrderType);
                    if (downloadPack != null)
                    {
                        while (!downloadPack.AssetReady)
                        {
                            assetPack.State = downloadPack.State;
                            yield return(null);
                        }

                        //资源交给AssetLoader;结束后删除wwwdownloader的任务;
                        assetPack.m_AssetBundle = downloadPack.Bundle;
                        assetPack.State         = downloadPack.State;
                    }
                    else
                    {
                        assetPack.State = AssetState.Finish;                            //临时处理,若不下载直接标记该资源已经被释放
                    }

                    WWWDownLoader.RemoveDownLoad(strNetLoadName, null);

                    if (isOnlyDownLoad)                    //如果预下载流程;
                    {
                        assetPack.UnloadAssetBundle(true); //only下载,下载完卸载资源,结束后删除wwwdownloader的任务;
                    }
                }
                else
                {
                    if (!isOnlyDownLoad)
                    {
                        IEnumerator itor = assetPack.LoadAsset(m_strAssetWWWDir, m_strAssetDir, m_strInAssetWWWDir, m_strAssetExtension);
                        while (itor.MoveNext())
                        {
                            yield return(null);
                        }
                    }
                    else
                    {
                        assetPack.State = AssetState.Finish;
                    }
                }

                if (assetPack.m_CallBack != null)
                {
                    assetPack.m_CallBack(assetName);
                }

                //下载完后判断是不是需要自主卸载,keepLoading的情况;
                assetPack.m_nKeepLoadingRefer = 0;
                if (!assetPack.m_IsResident && assetPack.m_AssetRefer <= 0 && assetPack.m_nKeepLoadingRefer <= 0)                //非常驻资源,没有外部使用,并且下载完成的情况下;
                {
                    ReleaseAsset(assetName, null, false);
                }
                else
                {
                    ReleaseDownLoadCoroutine(assetName);
                }
            }
            else
            {
                Debug.LogError("AssetLoader LoadingAsset, m_AllAssets dont has key : " + assetName);
            }
        }
示例#7
0
        private IEnumerator Load()
        {
            if (mResName.StartsWith("wing_") || mResName.StartsWith("hip_") ||
                mResName.StartsWith("lefthand_") || mResName.StartsWith("righthand_") ||
                mResName.StartsWith("shoulders_") ||
                mResName.StartsWith("leftear_") || mResName.StartsWith("rightear_"))
            {
                if (WWWDownLoaderConfig.CheckResNeedUpdate(mAssetName))
                {
                    DownLoadPack downloadPack = WWWDownLoader.InsertDownLoad(mAssetName, m_assetNetDir + mChildPath + mAssetName, DownLoadAssetType.AssetBundle, null, null, DownLoadOrderType.AfterRunning);
                    if (downloadPack != null)
                    {
                        while (!downloadPack.AssetReady)
                        {
                            yield return(null);
                        }
                        bundle = downloadPack.Bundle;
                    }
                    WWWDownLoader.RemoveDownLoad(mAssetName, null);
                }
                else
                {
                    string assetWWWPath = mAssetWWWDir + mChildPath + mAssetName;
                    string assetPath    = mAssetDir + mChildPath + mAssetName;
                    if (!File.Exists(assetPath))
                    {
                        assetWWWPath = mInAssetWWWDir + mChildPath + mAssetName;
                    }

                    using (m_www = new WWW(assetWWWPath))
                    {
                        while (m_www != null && !m_www.isDone)
                        {
                            yield return(null);
                        }

                        if (m_www != null)
                        {
                            if (m_www.error != null)
                            {
                                Debug.LogError(m_www.error);
                                Debug.LogError("Model Load Error! AssetName : " + mAssetName);
                            }
                            if (m_www != null)
                            {
                                bundle = m_www.assetBundle;
                            }

                            m_www.Dispose();
                            m_www = null;
                        }
                    }
                }
                if (bundle != null)
                {
                    request = bundle.LoadAsync(mAssetName.Replace(".clh", ""), typeof(GameObject));
                    while (request != null && !request.isDone)
                    {
                        yield return(null);
                    }
                    if (request != null)
                    {
                        modelPrefab = request.asset as GameObject;
                    }

                    if (CommonValue.PhoneOS == Phone_OS.Ios)
                    {
                        bundle.Unload(false);
                    }
                }
            }
            Messenger.Broadcast(MessangerEventDef.LOAD_ONEASSET_FINISH, MessengerMode.DONT_REQUIRE_LISTENER);
        }
示例#8
0
        private IEnumerator LoadRenderer()
        {
            if (!ResuceName.StartsWith("wing_") && !ResuceName.StartsWith("hip_") &&
                !ResuceName.StartsWith("lefthand_") && !ResuceName.StartsWith("righthand_") &&
                !ResuceName.StartsWith("skin_") &&
                !ResuceName.StartsWith("shoulders_") &&
                !ResuceName.StartsWith("leftear_") && !ResuceName.StartsWith("rightear_"))
            {
                if (WWWDownLoaderConfig.CheckResNeedUpdate(ResuceName))
                {
                    DownLoadPack downloadPack = WWWDownLoader.InsertDownLoad(ResuceName, m_assetNetDir + m_ChildPath + ResuceName, DownLoadAssetType.AssetBundle, null, null, DownLoadOrderType.AfterRunning);
                    if (downloadPack != null)
                    {
                        while (!downloadPack.AssetReady)
                        {
                            yield return(null);
                        }
                        m_AssetBundle = downloadPack.Bundle;
                    }
                    WWWDownLoader.RemoveDownLoad(ResuceName, null);
                }
                else
                {
                    string assetWWWPath = mAssetWWWDir + m_ChildPath + ResuceName;
                    string assetPath    = mAssetDir + m_ChildPath + ResuceName;
                    if (!File.Exists(assetPath))
                    {
                        assetWWWPath = mInAssetWWWDir + m_ChildPath + ResuceName;
                    }

                    WWW www = null;
                    using (www = new WWW(assetWWWPath))
                    {
                        while (!www.isDone)
                        {
                            yield return(null);
                        }

                        if (string.IsNullOrEmpty(www.error))
                        {
                            m_AssetBundle = www.assetBundle;
                        }
                        else
                        {
                            Debug.LogError(www.error + "." + ResuceName);
                        }

                        www.Dispose();
                        www = null;
                    }
                }

                if (m_AssetBundle != null)
                {
                    AssetBundleRequest gameObjectRequest = null;
                    AssetBundleRequest boneNameRequest   = null;

                    gameObjectRequest = m_AssetBundle.LoadAsync(ResuceName.Replace(".clh", ""), typeof(GameObject));
                    while (!gameObjectRequest.isDone)
                    {
                        yield return(null);
                    }

                    if (m_AssetBundle != null)
                    {
                        List <AssetBundleRequest> las = new List <AssetBundleRequest>();
                        m_Prefb = (GameObject)gameObjectRequest.asset;

                        if (m_Prefb != null)
                        {
                            foreach (SkinnedMeshRenderer smr in m_Prefb.GetComponentsInChildren <SkinnedMeshRenderer>(true))
                            {
                                boneNameRequest = m_AssetBundle.LoadAsync(smr.name.Replace("(Clone)", "") + "bonenames", typeof(object));
                                if (boneNameRequest != null)
                                {
                                    las.Insert(0, boneNameRequest);
                                }
                            }

                            while (las.Count != 0)
                            {
                                AssetBundleRequest gtABR = las[las.Count - 1];
                                if (gtABR == null)
                                {
                                    break;
                                }
                                if (gtABR.isDone)
                                {
                                    m_BoneNames.Add((object)gtABR.asset);
                                    las.RemoveAt(las.Count - 1);
                                }
                                yield return(null);
                            }
                        }

                        if (CommonValue.PhoneOS == Phone_OS.Ios)
                        {
                            m_AssetBundle.Unload(false);
                        }
                    }
                }
            }
            Messenger.Broadcast(MessangerEventDef.LOAD_ONEASSET_FINISH, MessengerMode.DONT_REQUIRE_LISTENER);
        }