using UnityEngine;
using System.Collections;
namespace Engine.CLoader
{
/// 资源加载对象
public class CLoaderAB
{
/// 下载对象
private WWW loader3W = null;
/// 是否下载完成
public bool IsLoadComplete = false;
/// 下载进度,例如进度是10%返回值是10
public int LoadProgress = 0;
/// 是否下载中
public bool IsLoadIng = false;
/// 加载的资源名称
public string assetsName = string.Empty;
/// 开始下载
public CLoaderAB(){ }
/// 开始下载
public void StartLoad(string path, string name)
{
assetsName = name;
IsLoadIng = true;
CDebug.Log(path);
loader3W = new WWW(path);
}
public AssetBundle assetsBundle
{
get
{
return loader3W.assetBundle;
}
}
/// 帧函数
public void OnUpdate()
{
if (loader3W == null)
{ return; }
if(loader3W.isDone)
{
//下载完成后的第二帧修改完成 标记
if (LoadProgress == 100)
{
IsLoadComplete = true;
}
LoadProgress = 100;
}
else
{
LoadProgress = (int)(loader3W.progress * 100);
}
}
/// 重置函数
public void Reset()
{
loader3W = null;
IsLoadComplete = false;
LoadProgress = 0;
IsLoadIng = false;
}
}
}