update file system
IFileSystem新增ReadFileData方法
This commit is contained in:
@@ -72,8 +72,7 @@ namespace YooAsset
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return null;
|
||||
string filePath = Provider.RawFilePath;
|
||||
return FileUtility.ReadAllBytes(filePath);
|
||||
return Provider.RawBundleObject.ReadFileData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,8 +82,7 @@ namespace YooAsset
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return null;
|
||||
string filePath = Provider.RawFilePath;
|
||||
return FileUtility.ReadAllText(filePath);
|
||||
return Provider.RawBundleObject.ReadFileText();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -94,7 +92,7 @@ namespace YooAsset
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return string.Empty;
|
||||
return Provider.RawFilePath;
|
||||
return Provider.RawBundleObject.GetFilePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace YooAsset
|
||||
public long DownloadedBytes { set; get; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 下载结果
|
||||
/// 加载结果
|
||||
/// </summary>
|
||||
public object Result { set; get; }
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
if (LoadBundleFileOp.Result is string == false)
|
||||
if (LoadBundleFileOp.Result is RawBundle == false)
|
||||
{
|
||||
string error = "Try load AssetBundle file using load raw file method !";
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
@@ -45,7 +45,7 @@ namespace YooAsset
|
||||
// 2. 检测加载结果
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
RawFilePath = LoadBundleFileOp.Result as string;
|
||||
RawBundleObject = LoadBundleFileOp.Result as RawBundle;
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace YooAsset
|
||||
// 2. 检测加载结果
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
RawFilePath = MainAssetInfo.AssetPath;
|
||||
RawBundleObject = new RawBundle(null, null, MainAssetInfo.AssetPath);
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -46,16 +46,16 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public UnityEngine.SceneManagement.Scene SceneObject { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取的原生对象
|
||||
/// </summary>
|
||||
public RawBundle RawBundleObject { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加载的场景名称
|
||||
/// </summary>
|
||||
public string SceneName { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 原生文件路径
|
||||
/// </summary>
|
||||
public string RawFilePath { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 引用计数
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RawBundle
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly PackageBundle _packageBundle;
|
||||
private readonly string _filePath;
|
||||
|
||||
internal RawBundle(IFileSystem fileSystem, PackageBundle packageBundle, string filePath)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageBundle = packageBundle;
|
||||
_filePath = filePath;
|
||||
}
|
||||
|
||||
public string GetFilePath()
|
||||
{
|
||||
return _filePath;
|
||||
}
|
||||
public byte[] ReadFileData()
|
||||
{
|
||||
if (_fileSystem != null)
|
||||
return _fileSystem.ReadFileData(_packageBundle);
|
||||
else
|
||||
return FileUtility.ReadAllBytes(_filePath);
|
||||
}
|
||||
public string ReadFileText()
|
||||
{
|
||||
if (_fileSystem != null)
|
||||
return _fileSystem.ReadFileText(_packageBundle);
|
||||
else
|
||||
return FileUtility.ReadAllText(_filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6e71c986d2a8c74d981deeed7b5a8ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user