Compare commits

..

No commits in common. "ce023cedb88dae9e255a68855a02daa7f44d3c2f" and "f861279c49d24e9031974017f6c2ff5bae0d4391" have entirely different histories.

9 changed files with 51 additions and 62 deletions

View File

@ -21,7 +21,7 @@ namespace YooAsset
} }
protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000); protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000);
protected readonly Dictionary<string, string> _buildinFilePathMapping = new Dictionary<string, string>(10000); protected readonly Dictionary<string, string> _buildinFilePaths = new Dictionary<string, string>(10000);
protected IFileSystem _unpackFileSystem; protected IFileSystem _unpackFileSystem;
protected string _packageRoot; protected string _packageRoot;
@ -309,10 +309,10 @@ namespace YooAsset
} }
public string GetBuildinFileLoadPath(PackageBundle bundle) public string GetBuildinFileLoadPath(PackageBundle bundle)
{ {
if (_buildinFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) if (_buildinFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
{ {
filePath = PathUtility.Combine(_packageRoot, bundle.FileName); filePath = PathUtility.Combine(_packageRoot, bundle.FileName);
_buildinFilePathMapping.Add(bundle.BundleGUID, filePath); _buildinFilePaths.Add(bundle.BundleGUID, filePath);
} }
return filePath; return filePath;
} }

View File

@ -11,10 +11,10 @@ namespace YooAsset
/// </summary> /// </summary>
internal class DefaultCacheFileSystem : IFileSystem internal class DefaultCacheFileSystem : IFileSystem
{ {
protected readonly Dictionary<string, RecordFileElement> _records = new Dictionary<string, RecordFileElement>(10000); protected readonly Dictionary<string, RecordFileElement> _wrappers = new Dictionary<string, RecordFileElement>(10000);
protected readonly Dictionary<string, string> _bundleDataFilePathMapping = new Dictionary<string, string>(10000); protected readonly Dictionary<string, string> _bundleDataFilePaths = new Dictionary<string, string>(10000);
protected readonly Dictionary<string, string> _bundleInfoFilePathMapping = new Dictionary<string, string>(10000); protected readonly Dictionary<string, string> _bundleInfoFilePaths = new Dictionary<string, string>(10000);
protected readonly Dictionary<string, string> _tempFilePathMapping = new Dictionary<string, string>(10000); protected readonly Dictionary<string, string> _tempFilePaths = new Dictionary<string, string>(10000);
protected DefaultCacheDownloadCenter _downloadCenter; protected DefaultCacheDownloadCenter _downloadCenter;
protected string _packageRoot; protected string _packageRoot;
@ -45,7 +45,7 @@ namespace YooAsset
{ {
get get
{ {
return _records.Count; return _wrappers.Count;
} }
} }
@ -245,7 +245,7 @@ namespace YooAsset
} }
public virtual bool Exists(PackageBundle bundle) public virtual bool Exists(PackageBundle bundle)
{ {
return _records.ContainsKey(bundle.BundleGUID); return _wrappers.ContainsKey(bundle.BundleGUID);
} }
public virtual bool NeedDownload(PackageBundle bundle) public virtual bool NeedDownload(PackageBundle bundle)
{ {
@ -330,60 +330,60 @@ namespace YooAsset
#region 缓存相关 #region 缓存相关
public List<string> GetAllCachedBundleGUIDs() public List<string> GetAllCachedBundleGUIDs()
{ {
return _records.Keys.ToList(); return _wrappers.Keys.ToList();
} }
public string GetTempFilePath(PackageBundle bundle) public string GetTempFilePath(PackageBundle bundle)
{ {
if (_tempFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) if (_tempFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
{ {
filePath = PathUtility.Combine(_tempFilesRoot, bundle.BundleGUID); filePath = PathUtility.Combine(_tempFilesRoot, bundle.BundleGUID);
_tempFilePathMapping.Add(bundle.BundleGUID, filePath); _tempFilePaths.Add(bundle.BundleGUID, filePath);
} }
return filePath; return filePath;
} }
public string GetBundleDataFilePath(PackageBundle bundle) public string GetBundleDataFilePath(PackageBundle bundle)
{ {
if (_bundleDataFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) if (_bundleDataFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
{ {
string folderName = bundle.FileHash.Substring(0, 2); string folderName = bundle.FileHash.Substring(0, 2);
filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleDataFileName); filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleDataFileName);
if (AppendFileExtension) if (AppendFileExtension)
filePath += bundle.FileExtension; filePath += bundle.FileExtension;
_bundleDataFilePathMapping.Add(bundle.BundleGUID, filePath); _bundleDataFilePaths.Add(bundle.BundleGUID, filePath);
} }
return filePath; return filePath;
} }
public string GetBundleInfoFilePath(PackageBundle bundle) public string GetBundleInfoFilePath(PackageBundle bundle)
{ {
if (_bundleInfoFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) if (_bundleInfoFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
{ {
string folderName = bundle.FileHash.Substring(0, 2); string folderName = bundle.FileHash.Substring(0, 2);
filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleInfoFileName); filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleInfoFileName);
_bundleInfoFilePathMapping.Add(bundle.BundleGUID, filePath); _bundleInfoFilePaths.Add(bundle.BundleGUID, filePath);
} }
return filePath; return filePath;
} }
public bool IsRecordBundleFile(string bundleGUID) public bool IsRecordBundleFile(string bundleGUID)
{ {
return _records.ContainsKey(bundleGUID); return _wrappers.ContainsKey(bundleGUID);
} }
public bool RecordBundleFile(string bundleGUID, RecordFileElement element) public bool RecordBundleFile(string bundleGUID, RecordFileElement element)
{ {
if (_records.ContainsKey(bundleGUID)) if (_wrappers.ContainsKey(bundleGUID))
{ {
YooLogger.Error($"{nameof(DefaultCacheFileSystem)} has element : {bundleGUID}"); YooLogger.Error($"{nameof(DefaultCacheFileSystem)} has element : {bundleGUID}");
return false; return false;
} }
_records.Add(bundleGUID, element); _wrappers.Add(bundleGUID, element);
return true; return true;
} }
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle) public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
{ {
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false) if (_wrappers.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
return EFileVerifyResult.CacheNotFound; return EFileVerifyResult.CacheNotFound;
EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High); EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
@ -391,7 +391,7 @@ namespace YooAsset
} }
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath) public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
{ {
if (_records.ContainsKey(bundle.BundleGUID)) if (_wrappers.ContainsKey(bundle.BundleGUID))
{ {
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
} }
@ -426,7 +426,7 @@ namespace YooAsset
} }
public bool DeleteCacheBundleFile(string bundleGUID) public bool DeleteCacheBundleFile(string bundleGUID)
{ {
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper)) if (_wrappers.TryGetValue(bundleGUID, out RecordFileElement wrapper))
{ {
try try
{ {
@ -434,7 +434,7 @@ namespace YooAsset
FileInfo fileInfo = new FileInfo(dataFilePath); FileInfo fileInfo = new FileInfo(dataFilePath);
if (fileInfo.Exists) if (fileInfo.Exists)
fileInfo.Directory.Delete(true); fileInfo.Directory.Delete(true);
_records.Remove(bundleGUID); _wrappers.Remove(bundleGUID);
return true; return true;
} }
catch (Exception e) catch (Exception e)

View File

@ -21,7 +21,7 @@ namespace YooAsset
} }
protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000); protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000);
protected readonly Dictionary<string, string> _webFilePathMapping = new Dictionary<string, string>(10000); protected readonly Dictionary<string, string> _webFilePaths = new Dictionary<string, string>(10000);
protected string _webPackageRoot = string.Empty; protected string _webPackageRoot = string.Empty;
/// <summary> /// <summary>
@ -173,10 +173,10 @@ namespace YooAsset
} }
public string GetWebFileLoadPath(PackageBundle bundle) public string GetWebFileLoadPath(PackageBundle bundle)
{ {
if (_webFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) if (_webFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
{ {
filePath = PathUtility.Combine(_webPackageRoot, bundle.FileName); filePath = PathUtility.Combine(_webPackageRoot, bundle.FileName);
_webFilePathMapping.Add(bundle.BundleGUID, filePath); _webFilePaths.Add(bundle.BundleGUID, filePath);
} }
return filePath; return filePath;
} }

View File

@ -20,7 +20,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 初始化文件系统 /// 初始化缓存系统
/// </summary> /// </summary>
FSInitializeFileSystemOperation InitializeFileSystemAsync(); FSInitializeFileSystemOperation InitializeFileSystemAsync();
@ -30,7 +30,7 @@ namespace YooAsset
FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout); FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout);
/// <summary> /// <summary>
/// 查询包裹版本 /// 查询最新的版本
/// </summary> /// </summary>
FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout); FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout);
@ -40,7 +40,7 @@ namespace YooAsset
FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam); FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam);
/// <summary> /// <summary>
/// 下载Bundle文件 /// 下载远端文件
/// </summary> /// </summary>
FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param); FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param);

View File

@ -52,12 +52,6 @@ internal class WXFSDownloadFileOperation : DefaultDownloadFileOperation
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
_fileSystem.TryRecordBundle(Bundle); //记录下载文件 _fileSystem.TryRecordBundle(Bundle); //记录下载文件
//TODO 解决微信小游戏插件问题
// Issue : https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/issues/108#
DownloadProgress = 1f;
DownloadedBytes = Bundle.FileSize;
Progress = 1f;
} }
else else
{ {

View File

@ -62,12 +62,6 @@ internal class WXFSLoadBundleOperation : FSLoadBundleOperation
Result = new WXAssetBundleResult(_fileSystem, _bundle, assetBundle); Result = new WXAssetBundleResult(_fileSystem, _bundle, assetBundle);
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
_fileSystem.TryRecordBundle(_bundle); //记录下载文件 _fileSystem.TryRecordBundle(_bundle); //记录下载文件
//TODO 解决微信小游戏插件问题
// Issue : https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/issues/108#
DownloadProgress = 1f;
DownloadedBytes = _bundle.FileSize;
Progress = 1f;
} }
} }
else else

View File

@ -34,26 +34,24 @@ internal class RecordWechatCacheFilesOperation : AsyncOperationBase
_steps = ESteps.WaitResponse; _steps = ESteps.WaitResponse;
var fileSystemMgr = _fileSystem.GetFileSystemMgr(); var fileSystemMgr = _fileSystem.GetFileSystemMgr();
var statOption = new WXStatOption(); var getSavedFileListOption = new GetSavedFileListOption();
statOption.path = _fileSystem.FileRoot; getSavedFileListOption.success = (GetSavedFileListSuccessCallbackResult response) =>
statOption.recursive = true;
statOption.success = (WXStatResponse response) =>
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
foreach (var fileStat in response.stats) foreach (var fileInfo in response.fileList)
{ {
//TODO 需要确认存储文件为Bundle文件 //TODO 需要确认存储文件为Bundle文件
_fileSystem.RecordBundleFile(_fileSystem.FileRoot + fileStat.path); _fileSystem.RecordBundleFile(fileInfo.filePath);
} }
}; };
statOption.fail = (WXStatResponse response) => getSavedFileListOption.fail = (FileError fileError) =>
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = response.errMsg; Error = fileError.errMsg;
}; };
fileSystemMgr.Stat(statOption); fileSystemMgr.GetSavedFileList(getSavedFileListOption);
} }
} }
} }

View File

@ -62,8 +62,6 @@ internal class WechatFileSystem : IFileSystem
/// 包裹名称 /// 包裹名称
/// </summary> /// </summary>
public string PackageName { private set; get; } public string PackageName { private set; get; }
private readonly string _packageRoot = YooAssetSettingsData.Setting.DefaultYooFolderName;
/// <summary> /// <summary>
/// 文件根目录 /// 文件根目录
@ -257,7 +255,7 @@ internal class WechatFileSystem : IFileSystem
{ {
if (_cacheFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) if (_cacheFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
{ {
filePath = PathUtility.Combine(_wxCacheRoot, "__GAME_FILE_CACHE", _packageRoot, bundle.FileName); filePath = PathUtility.Combine(_wxCacheRoot, bundle.FileName);
_cacheFilePaths.Add(bundle.BundleGUID, filePath); _cacheFilePaths.Add(bundle.BundleGUID, filePath);
} }
return filePath; return filePath;

View File

@ -1,12 +1,14 @@
#if UNITY_2019_4_OR_NEWER using System.Collections;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using YooAsset.Editor; using YooAsset.Editor;
#if UNITY_2019_4_OR_NEWER
using UnityEditor.UIElements; using UnityEditor.UIElements;
using UnityEngine.UIElements; using UnityEngine.UIElements;
#endif
[CreateAssetMenu(fileName = "TextureSchema", menuName = "YooAssetArt/Create TextureSchema")] [CreateAssetMenu(fileName = "TextureSchema", menuName = "YooAssetArt/Create TextureSchema")]
public class TextureSchema : ScannerSchema public class TextureSchema : ScannerSchema
@ -35,9 +37,9 @@ public class TextureSchema : ScannerSchema
public override ScanReport RunScanner(AssetArtScanner scanner) public override ScanReport RunScanner(AssetArtScanner scanner)
{ {
// 创建扫描报告 // 创建扫描报告
string name = "扫描所有纹理资产"; string title = "扫描所有纹理资产";
string desc = GetUserGuide(); string desc = GetUserGuide();
var report = new ScanReport(name, desc); var report = new ScanReport(title, desc);
report.AddHeader("资源路径", 600, 500, 1000).SetStretchable().SetSearchable().SetSortable().SetHeaderType(EHeaderType.AssetPath); report.AddHeader("资源路径", 600, 500, 1000).SetStretchable().SetSearchable().SetSortable().SetHeaderType(EHeaderType.AssetPath);
report.AddHeader("图片宽度", 100).SetSortable().SetHeaderType(EHeaderType.LongValue); report.AddHeader("图片宽度", 100).SetSortable().SetHeaderType(EHeaderType.LongValue);
report.AddHeader("图片高度", 100).SetSortable().SetHeaderType(EHeaderType.LongValue); report.AddHeader("图片高度", 100).SetSortable().SetHeaderType(EHeaderType.LongValue);
@ -103,9 +105,9 @@ public class TextureSchema : ScannerSchema
// 添加扫描信息 // 添加扫描信息
ReportElement result = new ReportElement(assetGUID); ReportElement result = new ReportElement(assetGUID);
result.AddScanInfo("资源路径", assetPath); result.AddScanInfo("资源路径", assetPath);
result.AddScanInfo("图片宽度", texture.width); result.AddScanInfo("图片宽度", texture.width.ToString());
result.AddScanInfo("图片高度", texture.height); result.AddScanInfo("图片高度", texture.height.ToString());
result.AddScanInfo("内存大小", memorySize); result.AddScanInfo("内存大小", memorySize.ToString());
result.AddScanInfo("苹果格式", iosFormat.ToString()); result.AddScanInfo("苹果格式", iosFormat.ToString());
result.AddScanInfo("安卓格式", androidFormat.ToString()); result.AddScanInfo("安卓格式", androidFormat.ToString());
result.AddScanInfo("错误信息", errorInfo); result.AddScanInfo("错误信息", errorInfo);
@ -155,6 +157,7 @@ public class TextureSchema : ScannerSchema
/// </summary> /// </summary>
public override SchemaInspector CreateInspector() public override SchemaInspector CreateInspector()
{ {
#if UNITY_2019_4_OR_NEWER
var container = new VisualElement(); var container = new VisualElement();
// 图片最大宽度 // 图片最大宽度
@ -180,6 +183,8 @@ public class TextureSchema : ScannerSchema
SchemaInspector inspector = new SchemaInspector(); SchemaInspector inspector = new SchemaInspector();
inspector.Containner = container; inspector.Containner = container;
return inspector; return inspector;
#else
return null;
#endif
} }
} }
#endif