mirror of https://github.com/tuyoogame/YooAsset
Compare commits
8 Commits
f861279c49
...
ce023cedb8
Author | SHA1 | Date |
---|---|---|
|
ce023cedb8 | |
|
3d1a28a50e | |
|
5d2d0b4168 | |
|
fa985a5a93 | |
|
40f9937b60 | |
|
c543c629c3 | |
|
0a96e583d3 | |
|
c9d263c60d |
|
@ -21,7 +21,7 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000);
|
||||
protected readonly Dictionary<string, string> _buildinFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _buildinFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected IFileSystem _unpackFileSystem;
|
||||
protected string _packageRoot;
|
||||
|
||||
|
@ -309,10 +309,10 @@ namespace YooAsset
|
|||
}
|
||||
public string GetBuildinFileLoadPath(PackageBundle bundle)
|
||||
{
|
||||
if (_buildinFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_buildinFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
filePath = PathUtility.Combine(_packageRoot, bundle.FileName);
|
||||
_buildinFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_buildinFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal class DefaultCacheFileSystem : IFileSystem
|
||||
{
|
||||
protected readonly Dictionary<string, RecordFileElement> _wrappers = new Dictionary<string, RecordFileElement>(10000);
|
||||
protected readonly Dictionary<string, string> _bundleDataFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _bundleInfoFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _tempFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, RecordFileElement> _records = new Dictionary<string, RecordFileElement>(10000);
|
||||
protected readonly Dictionary<string, string> _bundleDataFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _bundleInfoFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _tempFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected DefaultCacheDownloadCenter _downloadCenter;
|
||||
|
||||
protected string _packageRoot;
|
||||
|
@ -45,7 +45,7 @@ namespace YooAsset
|
|||
{
|
||||
get
|
||||
{
|
||||
return _wrappers.Count;
|
||||
return _records.Count;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ namespace YooAsset
|
|||
}
|
||||
public virtual bool Exists(PackageBundle bundle)
|
||||
{
|
||||
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||
return _records.ContainsKey(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool NeedDownload(PackageBundle bundle)
|
||||
{
|
||||
|
@ -330,60 +330,60 @@ namespace YooAsset
|
|||
#region 缓存相关
|
||||
public List<string> GetAllCachedBundleGUIDs()
|
||||
{
|
||||
return _wrappers.Keys.ToList();
|
||||
return _records.Keys.ToList();
|
||||
}
|
||||
|
||||
public string GetTempFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (_tempFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_tempFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
filePath = PathUtility.Combine(_tempFilesRoot, bundle.BundleGUID);
|
||||
_tempFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_tempFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
public string GetBundleDataFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (_bundleDataFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_bundleDataFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
string folderName = bundle.FileHash.Substring(0, 2);
|
||||
filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleDataFileName);
|
||||
if (AppendFileExtension)
|
||||
filePath += bundle.FileExtension;
|
||||
_bundleDataFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_bundleDataFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
public string GetBundleInfoFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (_bundleInfoFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_bundleInfoFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
string folderName = bundle.FileHash.Substring(0, 2);
|
||||
filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleInfoFileName);
|
||||
_bundleInfoFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_bundleInfoFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public bool IsRecordBundleFile(string bundleGUID)
|
||||
{
|
||||
return _wrappers.ContainsKey(bundleGUID);
|
||||
return _records.ContainsKey(bundleGUID);
|
||||
}
|
||||
public bool RecordBundleFile(string bundleGUID, RecordFileElement element)
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundleGUID))
|
||||
if (_records.ContainsKey(bundleGUID))
|
||||
{
|
||||
YooLogger.Error($"{nameof(DefaultCacheFileSystem)} has element : {bundleGUID}");
|
||||
return false;
|
||||
}
|
||||
|
||||
_wrappers.Add(bundleGUID, element);
|
||||
_records.Add(bundleGUID, element);
|
||||
return true;
|
||||
}
|
||||
|
||||
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
||||
{
|
||||
if (_wrappers.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
|
||||
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
|
||||
return EFileVerifyResult.CacheNotFound;
|
||||
|
||||
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)
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundle.BundleGUID))
|
||||
if (_records.ContainsKey(bundle.BundleGUID))
|
||||
{
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ namespace YooAsset
|
|||
}
|
||||
public bool DeleteCacheBundleFile(string bundleGUID)
|
||||
{
|
||||
if (_wrappers.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
||||
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -434,7 +434,7 @@ namespace YooAsset
|
|||
FileInfo fileInfo = new FileInfo(dataFilePath);
|
||||
if (fileInfo.Exists)
|
||||
fileInfo.Directory.Delete(true);
|
||||
_wrappers.Remove(bundleGUID);
|
||||
_records.Remove(bundleGUID);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000);
|
||||
protected readonly Dictionary<string, string> _webFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _webFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected string _webPackageRoot = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
|
@ -173,10 +173,10 @@ namespace YooAsset
|
|||
}
|
||||
public string GetWebFileLoadPath(PackageBundle bundle)
|
||||
{
|
||||
if (_webFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_webFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
filePath = PathUtility.Combine(_webPackageRoot, bundle.FileName);
|
||||
_webFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_webFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace YooAsset
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化缓存系统
|
||||
/// 初始化文件系统
|
||||
/// </summary>
|
||||
FSInitializeFileSystemOperation InitializeFileSystemAsync();
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace YooAsset
|
|||
FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout);
|
||||
|
||||
/// <summary>
|
||||
/// 查询最新的版本
|
||||
/// 查询包裹版本
|
||||
/// </summary>
|
||||
FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout);
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace YooAsset
|
|||
FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam);
|
||||
|
||||
/// <summary>
|
||||
/// 下载远端文件
|
||||
/// 下载Bundle文件
|
||||
/// </summary>
|
||||
FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param);
|
||||
|
||||
|
|
|
@ -52,6 +52,12 @@ internal class WXFSDownloadFileOperation : DefaultDownloadFileOperation
|
|||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
_fileSystem.TryRecordBundle(Bundle); //记录下载文件
|
||||
|
||||
//TODO 解决微信小游戏插件问题
|
||||
// Issue : https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/issues/108#
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = Bundle.FileSize;
|
||||
Progress = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -62,6 +62,12 @@ internal class WXFSLoadBundleOperation : FSLoadBundleOperation
|
|||
Result = new WXAssetBundleResult(_fileSystem, _bundle, assetBundle);
|
||||
Status = EOperationStatus.Succeed;
|
||||
_fileSystem.TryRecordBundle(_bundle); //记录下载文件
|
||||
|
||||
//TODO 解决微信小游戏插件问题
|
||||
// Issue : https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/issues/108#
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
Progress = 1f;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -34,24 +34,26 @@ internal class RecordWechatCacheFilesOperation : AsyncOperationBase
|
|||
_steps = ESteps.WaitResponse;
|
||||
|
||||
var fileSystemMgr = _fileSystem.GetFileSystemMgr();
|
||||
var getSavedFileListOption = new GetSavedFileListOption();
|
||||
getSavedFileListOption.success = (GetSavedFileListSuccessCallbackResult response) =>
|
||||
var statOption = new WXStatOption();
|
||||
statOption.path = _fileSystem.FileRoot;
|
||||
statOption.recursive = true;
|
||||
statOption.success = (WXStatResponse response) =>
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
foreach (var fileInfo in response.fileList)
|
||||
foreach (var fileStat in response.stats)
|
||||
{
|
||||
//TODO 需要确认存储文件为Bundle文件
|
||||
_fileSystem.RecordBundleFile(fileInfo.filePath);
|
||||
_fileSystem.RecordBundleFile(_fileSystem.FileRoot + fileStat.path);
|
||||
}
|
||||
};
|
||||
getSavedFileListOption.fail = (FileError fileError) =>
|
||||
statOption.fail = (WXStatResponse response) =>
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = fileError.errMsg;
|
||||
Error = response.errMsg;
|
||||
};
|
||||
fileSystemMgr.GetSavedFileList(getSavedFileListOption);
|
||||
fileSystemMgr.Stat(statOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,8 @@ internal class WechatFileSystem : IFileSystem
|
|||
/// 包裹名称
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
private readonly string _packageRoot = YooAssetSettingsData.Setting.DefaultYooFolderName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件根目录
|
||||
|
@ -255,7 +257,7 @@ internal class WechatFileSystem : IFileSystem
|
|||
{
|
||||
if (_cacheFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
filePath = PathUtility.Combine(_wxCacheRoot, bundle.FileName);
|
||||
filePath = PathUtility.Combine(_wxCacheRoot, "__GAME_FILE_CACHE", _packageRoot, bundle.FileName);
|
||||
_cacheFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
using System.Collections;
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using YooAsset.Editor;
|
||||
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
#endif
|
||||
|
||||
[CreateAssetMenu(fileName = "TextureSchema", menuName = "YooAssetArt/Create TextureSchema")]
|
||||
public class TextureSchema : ScannerSchema
|
||||
|
@ -37,9 +35,9 @@ public class TextureSchema : ScannerSchema
|
|||
public override ScanReport RunScanner(AssetArtScanner scanner)
|
||||
{
|
||||
// 创建扫描报告
|
||||
string title = "扫描所有纹理资产";
|
||||
string name = "扫描所有纹理资产";
|
||||
string desc = GetUserGuide();
|
||||
var report = new ScanReport(title, desc);
|
||||
var report = new ScanReport(name, desc);
|
||||
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);
|
||||
|
@ -105,9 +103,9 @@ public class TextureSchema : ScannerSchema
|
|||
// 添加扫描信息
|
||||
ReportElement result = new ReportElement(assetGUID);
|
||||
result.AddScanInfo("资源路径", assetPath);
|
||||
result.AddScanInfo("图片宽度", texture.width.ToString());
|
||||
result.AddScanInfo("图片高度", texture.height.ToString());
|
||||
result.AddScanInfo("内存大小", memorySize.ToString());
|
||||
result.AddScanInfo("图片宽度", texture.width);
|
||||
result.AddScanInfo("图片高度", texture.height);
|
||||
result.AddScanInfo("内存大小", memorySize);
|
||||
result.AddScanInfo("苹果格式", iosFormat.ToString());
|
||||
result.AddScanInfo("安卓格式", androidFormat.ToString());
|
||||
result.AddScanInfo("错误信息", errorInfo);
|
||||
|
@ -157,7 +155,6 @@ public class TextureSchema : ScannerSchema
|
|||
/// </summary>
|
||||
public override SchemaInspector CreateInspector()
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
var container = new VisualElement();
|
||||
|
||||
// 图片最大宽度
|
||||
|
@ -183,8 +180,6 @@ public class TextureSchema : ScannerSchema
|
|||
SchemaInspector inspector = new SchemaInspector();
|
||||
inspector.Containner = container;
|
||||
return inspector;
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue