Example #1
0
		public IEnumerator ReadStored (CacheItem _config, AppGuiResponse _appGui, MonoBehaviour _component, AssetBundleDelegate _callback) //AssetBundleBigDelegate _callbackParam
		{
			AssetBundle res = null;
			bool complete = false;
			if (_config == null) {
				yield return _component.StartCoroutine(_callback (res));//,_appGui,_config, _callbackParam);
			} else {
				if (PlayerPrefs.GetInt ("debug") == 1)Debug.Log ("DeveloperContainer.ReadStored _config.strategy=" + _config.strategy + " _config.item=" + _config.item+" _config.type"+_config.type);
				if (_config.strategy == CacheStrategy.Version) {
					if (cacheVersion.ContainsKey (_config.fileName)) {
						if (_appGui.bundle.version > cacheVersion [_config.fileName]){
							yield return _component.StartCoroutine(_callback(res));//,_appGui,_config, _callbackParam));
							complete=true;
						}
					} else {
							yield return _component.StartCoroutine(_callback(res));//,_appGui,_config, _callbackParam));
						complete=true;
					}
				}
				if (complete==false) {
					if (_config.strategy == CacheStrategy.NoCache){
						ReadResource (_config,_appGui,_component, _callback);
					}else{
						yield return _component.StartCoroutine(ReadCache (_appGui,_component, _callback, delegate(AssetBundle _assetBundle){
							if (_assetBundle==null){ 
								ReadResource (_config,_appGui,_component, _callback);
							}
						}));
					}
					complete=true;
				}
				if (!complete) 
					yield return _component.StartCoroutine(_callback (res));//,_appGui,_config, _callbackParam));
			}
		}
Example #2
0
		public IEnumerator ReadResourceCor (CacheItem _config, AppGuiResponse _appGui,MonoBehaviour _component, AssetBundleDelegate _callback)
		{
			if (_config == null) {
				yield return _component.StartCoroutine (_callback (null));
			} else {
				AssetBundle ab=null;
				try{
					TextAsset fileAsText  = Resources.Load( "cache/" + _config.type + "/" + _appGui.bundle.name) as TextAsset;
					if ( fileAsText != null )
					{
						byte[] bundleData  = fileAsText.bytes.Clone() as byte[];
						AssetBundleCreateRequest  abcr= AssetBundle.LoadFromMemoryAsync( bundleData );
						ab=abcr.assetBundle;
					}
				}catch{
				}
				yield return _component.StartCoroutine (_callback (ab));
			}
		}
Example #3
0
		public IEnumerator ReadCache (AppGuiResponse _appGui,  MonoBehaviour _component, AssetBundleDelegate _callback, AssetBundleDelegateFunc _callback2)
		{
			AssetBundle res=null;
				#if UNITY_WEBGL
					yield return _component.StartCoroutine(_callback(res));
				#else
					WWW www=null;
					if (System.IO.File.Exists(Application.persistentDataPath+"/cache/"+CacheType.Assetbundle+"/"+_appGui.bundle.name+".unity3d")){ 
						www = WWW.LoadFromCacheOrDownload("file://"+Application.persistentDataPath+"/cache/"+CacheType.Assetbundle+"/"+_appGui.bundle.name+".unity3d",_appGui.bundle.version);
						yield return www;
					}
					if (www==null||(www.error!=null&&www.error!="")){
						if (www!=null) Debug.LogError("DeveloperContainer.ReadCache error="+www.error);
						_callback2(null);
					}else{
						_callback2(www.assetBundle);	
						yield return _component.StartCoroutine(_callback(www.assetBundle));
					}
				#endif
		}
Example #4
0
		public void ReadResource (CacheItem _config, AppGuiResponse _appGui,MonoBehaviour _component, AssetBundleDelegate _callback)
		{
			_component.StartCoroutine (ReadResourceCor (_config, _appGui, _component, _callback));
		}