Beispiel #1
0
 public UnityEngine.Object LoadObject(string path, Action <UnityEngine.Object> actEnd = null, bool showAlert = true)
 {
     if (actEnd == null && AssetDataCacheMng.Instance() != null)
     {
         bool flag = AssetDataCacheMng.Instance().IsCacheExist(path);
         if (flag)
         {
             return(AssetDataCacheMng.Instance().GetCache(path));
         }
     }
     UnityEngine.Object @object;
     if (this.USE_ASSET_BUNDLE == ABPrefabType.None)
     {
         @object = Resources.Load(path);
     }
     else
     {
         if (this.USE_RESOURCE_DATA_FOR_AB)
         {
             @object = Resources.Load(path);
         }
         else if (this.IsAssetBundleData(path))
         {
             @object = null;
         }
         else
         {
             @object = Resources.Load(path);
         }
         if (@object == null)
         {
             string resourceName = string.Empty;
             for (int i = 0; i < this.abidList.Count; i++)
             {
                 if (path.Length > this.abidList[i].abPath.Length && path.StartsWith(this.abidList[i].abPath))
                 {
                     resourceName = path.Substring(this.abidList[i].abPath.Length);
                     if (actEnd != null)
                     {
                         if (AssetBundleMng.Instance().LoadObjectASync(this.abidList[i], resourceName, actEnd))
                         {
                             return(null);
                         }
                     }
                     else
                     {
                         @object = AssetBundleMng.Instance().LoadObject(this.abidList[i], resourceName);
                         if (!(@object == null))
                         {
                             break;
                         }
                     }
                 }
             }
             global::Debug.Assert(null != @object, "AssetDataMng:LoadObject = " + path + "がない");
         }
     }
     if (@object == null && showAlert)
     {
         string messageString = string.Empty;
         if (File.Exists(path))
         {
             messageString = StringMaster.GetString("AlertFileErrorMemory");
         }
         else
         {
             messageString = StringMaster.GetString("AlertFileErrorNotFound");
         }
         NativeMessageDialog.Show(messageString);
     }
     if (actEnd != null)
     {
         actEnd(@object);
     }
     return(@object);
 }
	public AB_DownLoadInfo DownLoad_OneAssetBundleData(string catName, int ver, string abPath, AssetBundleInfo abInfo, Action<AssetBundle, AB_DownLoadInfo> actEnd = null, bool forceDL = false)
	{
		AB_DownLoadInfo abdlI = new AB_DownLoadInfo
		{
			ver = ver,
			abPath = abPath,
			abInfo = abInfo,
			actEndCallBack = actEnd,
			progress = 0f
		};
		string text = string.Empty;
		string strROOT = string.Empty;
		strROOT = this.GetAssetBundleRootPath();
		text = strROOT + abdlI.abPath + abdlI.abInfo.abName;
		text = text + ".unity3d?" + AssetDataMng.assetVersion;
		uint crc = abdlI.abInfo.crc;
		uint recordCRC = this.GetRecordCRC(abdlI.abPath, abdlI.abInfo.abName);
		int recordVersion = this.GetRecordVersion(abdlI.abPath, abdlI.abInfo.abName);
		if (abdlI.actEndCallBack != null)
		{
			Action action;
			if (forceDL && recordVersion != -1)
			{
				abdlI.ver = recordVersion;
				action = delegate()
				{
					this.StartCoroutine(this.WaitResponse_DownLoad(abdlI, strROOT, forceDL));
				};
			}
			else
			{
				forceDL = false;
				if (this.level != string.Empty && this.level != abdlI.abInfo.level.Trim())
				{
					action = delegate()
					{
						abdlI.actEndCallBack(null, abdlI);
					};
				}
				else if (recordVersion == -1)
				{
					abdlI.ver = 1;
					action = delegate()
					{
						this.StartCoroutine(this.WaitResponse_DownLoad(abdlI, strROOT, false));
					};
				}
				else if (recordCRC != crc)
				{
					abdlI.ver = recordVersion;
					action = delegate()
					{
						this.StartCoroutine(this.WaitResponse_DownLoad(abdlI, strROOT, false));
					};
				}
				else
				{
					Hash128 hash = new Hash128(0u, 0u, 0u, (uint)recordVersion);
					bool flag = Caching.IsVersionCached(text, hash);
					if (flag)
					{
						Caching.MarkAsUsed(text, hash);
						action = delegate()
						{
							abdlI.actEndCallBack(null, abdlI);
						};
					}
					else
					{
						abdlI.ver = recordVersion;
						action = delegate()
						{
							this.StartCoroutine(this.WaitResponse_DownLoad(abdlI, strROOT, false));
						};
					}
				}
			}
			this.waitDownLoadCT = 1;
			base.StartCoroutine(this.DownLoad(action));
			return abdlI;
		}
		Hash128 hash2 = new Hash128(0u, 0u, 0u, 1u);
		bool flag2 = Caching.IsVersionCached(text, hash2);
		if (flag2)
		{
			abdlI.www = WWW.LoadFromCacheOrDownload(text, hash2, 0u);
			while (!abdlI.www.isDone)
			{
				Thread.Sleep(1);
			}
			return abdlI;
		}
		abdlI.ver = recordVersion;
		forceDL = false;
		base.StartCoroutine(this.ReloadFromWWW(abdlI, strROOT));
		string text2 = text.Substring(text.IndexOf("AB_DATA/"));
		string text3 = text2;
		text2 = string.Concat(new string[]
		{
			text3,
			"\n存在するはずのファイルがキャッシュに存在しません!\n CRC = ",
			recordCRC.ToString(),
			",  VER = ",
			recordVersion.ToString()
		});
		NativeMessageDialog.Show(text2);
		return abdlI;
	}