Пример #1
0
    IEnumerator ChangeAd()
    {
        if (m_lstADTex.Count <= 1)
        {
            List <string> loadingList = new List <string>();
            loadingList.Add("loading_ad-01");
            int loadingADCount = loadingList.Count;
            for (int i = 0; i < loadingADCount; ++i)
            {
                string loadingad = loadingList[i];
                string adPath    = CommonValue.UITextureDir + loadingad + "." + AssetBundleType.Texture.ToString().ToLower();
                if (!File.Exists(adPath))
                {
                    adPath = CommonValue.InUITextureDir + loadingad + "." + AssetBundleType.Texture.ToString().ToLower();
                }

                if (File.Exists(adPath) || WWWDownLoaderConfig.CheckResNeedUpdate(loadingad + "." + AssetBundleType.Texture.ToString().ToLower()))
                {
                    m_lstADTex.Add(loadingad);
                }
            }
        }

        int adIndex = 0;

        if (m_lstADTex.Count > 1)
        {
            adIndex = Random.Range(1, m_lstADTex.Count);                // 索引从1开始,表示只关心服务器上数据
        }

        if (m_nADIndex != adIndex)
        {
            string adOld = "";
            if (m_nADIndex >= 0 && m_nADIndex < m_lstADTex.Count)
            {
                adOld = m_lstADTex[m_nADIndex];
            }

            m_nADIndex = adIndex;
            string adNew = m_lstADTex[m_nADIndex];

            IEnumerator itor = ShowLoadingTexture(adNew, adOld);
            while (itor.MoveNext())
            {
                yield return(null);
            }
        }
    }
Пример #2
0
        public IEnumerator Load(string strFileName)
        {
            byte[] gtBytes = null;
            if (WWWDownLoaderConfig.CheckResNeedUpdate(strFileName))
            {
                DownLoadPack downloadPack = WWWDownLoader.InsertDownLoad(strFileName, CommonValue.NetStaDataDir + strFileName, DownLoadAssetType.Text, null, null, DownLoadOrderType.AfterRunning);
                if (downloadPack != null)
                {
                    while (!downloadPack.AssetReady)
                    {
                        yield return(null);
                    }
                    gtBytes = downloadPack.DataBytes;
                }
                WWWDownLoader.RemoveDownLoad(strFileName, null);
            }
            else
            {
                if (!string.IsNullOrEmpty(strFileName))
                {
                    string assetWWWPath = CommonValue.StaDataWWWDir + strFileName;
                    string assetPath    = CommonValue.StaDataDir + strFileName;
                    if (!File.Exists(assetPath))
                    {
                        assetWWWPath = CommonValue.InStaDataWWWDir + strFileName;
                        assetPath    = CommonValue.InStaDataDir + strFileName;
                    }

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

                        if (www.error != null)
                        {
                            Debug.LogError(www.error);
                            Debug.LogError("StaticData Load Error! AssetName : " + strFileName);
                        }
                        else
                        {
                            gtBytes = www.bytes;
                        }

                        www.Dispose();
                        www = null;
                    }
                }
                else
                {
                    Debug.LogError("StaticData load error, FileName can not be null.");
                }
            }

            if (gtBytes != null)
            {
                LoadDataFromBuffer(gtBytes);
            }
            gtBytes = null;
            //Messenger.Broadcast(MessangerEventDef.LOAD_ONEASSET_FINISH, MessengerMode.DONT_REQUIRE_LISTENER);
        }