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