101 lines
2.4 KiB
C#
101 lines
2.4 KiB
C#
|
using System;
|
|||
|
using Thousandto.Update.Delegate;
|
|||
|
|
|||
|
|
|||
|
namespace Thousandto.Update.Trans
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// UILoginFormScript的逻辑处理类
|
|||
|
/// </summary>
|
|||
|
public class TransResource
|
|||
|
{
|
|||
|
//@"H:\Qinji2\Client\Target\test1.apk";
|
|||
|
protected string _resourcePath;
|
|||
|
//@"H:\Qinji2\Client\Target";//Application.streamingAssetsPath;
|
|||
|
protected string _outPath;
|
|||
|
|
|||
|
protected int nReadCount = 0;
|
|||
|
protected int nWriteCount = 0;
|
|||
|
|
|||
|
protected int _bufferSize = 1024 * 10;
|
|||
|
protected byte[] _buffer = new byte[1024 * 10];
|
|||
|
|
|||
|
//转移资源成功
|
|||
|
protected bool _success = false;
|
|||
|
|
|||
|
protected TransResourceFinishCallback _finishCallback;
|
|||
|
|
|||
|
//内部流程处理的回调
|
|||
|
protected Action _internalFinishCallback;
|
|||
|
|
|||
|
//是否释放obb资源
|
|||
|
public bool IsUnZipObb = false;
|
|||
|
|
|||
|
public void SetUnzipPath(string sourcePath, string outPath, TransResourceFinishCallback callback)
|
|||
|
{
|
|||
|
_resourcePath = sourcePath;
|
|||
|
_outPath = outPath;
|
|||
|
_finishCallback = callback;
|
|||
|
}
|
|||
|
|
|||
|
public virtual void StartUnzipByThread()
|
|||
|
{
|
|||
|
BeginTransRes();
|
|||
|
}
|
|||
|
|
|||
|
public virtual void BeginTransRes()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public void ReInit()
|
|||
|
{
|
|||
|
nReadCount = 0;
|
|||
|
nWriteCount = 0;
|
|||
|
}
|
|||
|
|
|||
|
public int GetCurrentProgress()
|
|||
|
{
|
|||
|
return nWriteCount;
|
|||
|
}
|
|||
|
|
|||
|
public float GetCurrentProgressValue()
|
|||
|
{
|
|||
|
if (nReadCount == 0)
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
return (float)nWriteCount / (float)nReadCount;
|
|||
|
}
|
|||
|
|
|||
|
public int GetTotalValue()
|
|||
|
{
|
|||
|
return nReadCount;
|
|||
|
}
|
|||
|
|
|||
|
//转移资源结果
|
|||
|
public bool GetTransReslult()
|
|||
|
{
|
|||
|
return _success;
|
|||
|
}
|
|||
|
|
|||
|
public virtual void CallFinish(bool success)
|
|||
|
{
|
|||
|
if (_finishCallback != null)
|
|||
|
{
|
|||
|
_finishCallback(success);
|
|||
|
_finishCallback = null;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal void SetInternalCallback(Action callback)
|
|||
|
{
|
|||
|
_internalFinishCallback = callback;
|
|||
|
}
|
|||
|
|
|||
|
internal void CallInternalCallback()
|
|||
|
{
|
|||
|
if (_internalFinishCallback != null)
|
|||
|
_internalFinishCallback();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|