예제 #1
0
	IEnumerator beginMoveAssetBundle (string[] _list)
	{
		WWW loader;
		for (int i=0; i<_list.Length; i++) {
			string each = _list [i];
			loader = new WWW (PathKit.GetStreamingAssetsPath (each));
			yield return loader;
			
			PathKit.CreateDirIfNotExists (PathKit.GetURLPath (each, false, true));
			FileStream fs = File.OpenWrite (PathKit.GetURLPath (each, false, true));
			
			//	new FileStream(PathKit.GetURLPath(each,false),FileMode.OpenOrCreate ,FileAccess.ReadWrite);
			fs.Write (loader.bytes, 0, loader.bytes.Length);
			fs.Close ();
			fs.Dispose ();

//			MonoBase.print (PathKit.GetURLPath (each, false, true) + "     write ok!!!");
			
			if (i == _list.Length - 1)
				GameManager.Instance.PrepareResourcesOK ();
			
			if (GameManager.Instance.guide != null)
				GameManager.Instance.guide.progress.text = (int)((float)(i + 1) / (float)_list.Length * 100) + "%";
			
		}
	}
예제 #2
0
	//读取一系列AssetBundle镜像,这会在内存划分一块区域存放;
	IEnumerator  LoadAssetBundleImage (List<string> paths, CallBack<List<ResourcesData>> Callback, string key)
	{

		WWW loader = null;
		bool canCall = false;//判断是否最后一个
		List<ResourcesData> _list = new List<ResourcesData> ();
		
		for (int i=0; i<paths.Count; i++) {
			
			//如果是最后一个
			if (i == paths.Count - 1) {
				canCall = true;
			}
			
			//缓存进度
			cacheProgress = ((float)i + 1f) / (float)paths.Count - 0.1f;
			if (GameManager.Instance.guide != null) {
				GameManager.Instance.guide.progress.text = ((int)((i) / (float)paths.Count * 100)).ToString () + "%";
			}
			
			string each = paths [i];
			if (string.IsNullOrEmpty (each))
				continue;
			string _path = PathKit.GetURLPath (each, true, true);
			
			ResourcesData _tmp = new ResourcesData ();	
			if (File.Exists (PathKit.GetURLPath (each, false, true)) && GameManager.Instance. ignoreUpdate==false) {
				_tmp.ResType = ResourcesData_type.AssetBundleRes;
			} else {
				
				//外部更新文件夹没有的话,尝试读取内部资源
				if (!GameManager.Instance.allowLoadFromRes) {
		
					_path = PathKit.GetStreamingAssetsPath (each);

				} else {
					_path = "";
				}
				
			}
			if (string.IsNullOrEmpty (_path) == false) {
				loader = new WWW (_path);
				yield return loader;
				if (loader.assetBundle == null) {
//					Debug.LogError (_path + "   downLoad assetBundle is null ");
					
				} else {
					
					_tmp.ResourcesBundle = loader.assetBundle;
					_tmp.ResourcesPath = _path;
					_tmp.ResourcesName = each;		
					_tmp.size = loader.bytes.LongLength;
					loader.Dispose ();
					
					if (allDataList.ContainsKey (key))
						allDataList [key].Add (_tmp.ResourcesName, _tmp);

					changeSize (key, _tmp.size);
					_list.Add (_tmp);
					
				}
			} else {
//				Debug.LogError (each + "   is empty  path");
			}
			
			if (Callback != null && canCall == true) {
				//缓冲完成后回调.
				cacheProgress = 1;
				Callback (_list);		
				Callback = null;
			}
		}
	}