Compare commits

...

6 Commits

Author SHA1 Message Date
hevinci
396ec7121c Update CHANGELOG.md 2023-04-08 11:18:36 +08:00
hevinci
e403c80d51 Update package.json 2023-04-08 11:18:30 +08:00
hevinci
aac315826e update asset bundle collector
修复了通过代码途径导入XML配置的报错问题。
2023-04-07 16:07:24 +08:00
hevinci
567c34d4d1 fix #95
修复了原生文件不支持ini格式文件的问题。
2023-04-06 16:32:50 +08:00
hevinci
896681df87 update asset system
修复了资源文件路径无效导致异常的问题。
2023-04-06 16:15:25 +08:00
hevinci
e278883958 update docs 2023-03-30 17:41:42 +08:00
14 changed files with 73 additions and 79 deletions

View File

@@ -2,6 +2,14 @@
All notable changes to this package will be documented in this file. All notable changes to this package will be documented in this file.
## [1.4.10] - 2023-04-08
### Fixed
- 修复了资源文件路径无效导致异常的问题。
- 修复了原生文件不支持ini格式文件的问题。
- 修复了通过代码途径导入XML配置的报错问题。
## [1.4.9] - 2023-03-29 ## [1.4.9] - 2023-03-29
### Fixed ### Fixed

View File

@@ -243,8 +243,8 @@ namespace YooAsset.Editor
return false; return false;
// 忽略编辑器下的类型资源 // 忽略编辑器下的类型资源
Type type = AssetDatabase.GetMainAssetTypeAtPath(assetPath); Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
if (type == typeof(LightingDataAsset)) if (assetType == typeof(LightingDataAsset))
return false; return false;
// 检测原生文件是否合规 // 检测原生文件是否合规
@@ -252,27 +252,29 @@ namespace YooAsset.Editor
{ {
string extension = StringUtility.RemoveFirstChar(System.IO.Path.GetExtension(assetPath)); string extension = StringUtility.RemoveFirstChar(System.IO.Path.GetExtension(assetPath));
if (extension == EAssetFileExtension.unity.ToString() || extension == EAssetFileExtension.prefab.ToString() || if (extension == EAssetFileExtension.unity.ToString() || extension == EAssetFileExtension.prefab.ToString() ||
extension == EAssetFileExtension.mat.ToString() || extension == EAssetFileExtension.controller.ToString() || extension == EAssetFileExtension.fbx.ToString() || extension == EAssetFileExtension.mat.ToString() ||
extension == EAssetFileExtension.fbx.ToString() || extension == EAssetFileExtension.anim.ToString() || extension == EAssetFileExtension.controller.ToString() || extension == EAssetFileExtension.anim.ToString() ||
extension == EAssetFileExtension.shader.ToString()) extension == EAssetFileExtension.ttf.ToString() || extension == EAssetFileExtension.shader.ToString())
{ {
UnityEngine.Debug.LogWarning($"Raw file pack rule can not support file estension : {extension}"); UnityEngine.Debug.LogWarning($"Raw file pack rule can not support file estension : {extension}");
return false; return false;
} }
// 注意:原生文件只支持无依赖关系的资源 // 注意:原生文件只支持无依赖关系的资源
/*
string[] depends = AssetDatabase.GetDependencies(assetPath, true); string[] depends = AssetDatabase.GetDependencies(assetPath, true);
if (depends.Length != 1) if (depends.Length != 1)
{ {
UnityEngine.Debug.LogWarning($"Raw file pack rule can not support estension : {extension}"); UnityEngine.Debug.LogWarning($"Raw file pack rule can not support estension : {extension}");
return false; return false;
} }
*/
} }
else else
{ {
// 忽略Unity无法识别的无效文件 // 忽略Unity无法识别的无效文件
// 注意:只对非原生文件收集器处理 // 注意:只对非原生文件收集器处理
if (type == typeof(UnityEditor.DefaultAsset)) if (assetType == typeof(UnityEditor.DefaultAsset))
{ {
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}"); UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
return false; return false;

View File

@@ -27,24 +27,8 @@ namespace YooAsset.Editor
public static bool IsDirty { private set; get; } = false; public static bool IsDirty { private set; get; } = false;
private static AssetBundleCollectorSetting _setting = null; static AssetBundleCollectorSettingData()
public static AssetBundleCollectorSetting Setting
{ {
get
{
if (_setting == null)
LoadSettingData();
return _setting;
}
}
/// <summary>
/// 加载配置文件
/// </summary>
private static void LoadSettingData()
{
_setting = SettingLoader.LoadSettingData<AssetBundleCollectorSetting>();
// IPackRule // IPackRule
{ {
// 清空缓存集合 // 清空缓存集合
@@ -147,6 +131,17 @@ namespace YooAsset.Editor
} }
} }
private static AssetBundleCollectorSetting _setting = null;
public static AssetBundleCollectorSetting Setting
{
get
{
if (_setting == null)
_setting = SettingLoader.LoadSettingData<AssetBundleCollectorSetting>();
return _setting;
}
}
/// <summary> /// <summary>
/// 存储配置文件 /// 存储配置文件
/// </summary> /// </summary>
@@ -184,9 +179,6 @@ namespace YooAsset.Editor
public static List<RuleDisplayName> GetActiveRuleNames() public static List<RuleDisplayName> GetActiveRuleNames()
{ {
if (_setting == null)
LoadSettingData();
List<RuleDisplayName> names = new List<RuleDisplayName>(); List<RuleDisplayName> names = new List<RuleDisplayName>();
foreach (var pair in _cacheActiveRuleTypes) foreach (var pair in _cacheActiveRuleTypes)
{ {
@@ -199,9 +191,6 @@ namespace YooAsset.Editor
} }
public static List<RuleDisplayName> GetAddressRuleNames() public static List<RuleDisplayName> GetAddressRuleNames()
{ {
if (_setting == null)
LoadSettingData();
List<RuleDisplayName> names = new List<RuleDisplayName>(); List<RuleDisplayName> names = new List<RuleDisplayName>();
foreach (var pair in _cacheAddressRuleTypes) foreach (var pair in _cacheAddressRuleTypes)
{ {
@@ -214,9 +203,6 @@ namespace YooAsset.Editor
} }
public static List<RuleDisplayName> GetPackRuleNames() public static List<RuleDisplayName> GetPackRuleNames()
{ {
if (_setting == null)
LoadSettingData();
List<RuleDisplayName> names = new List<RuleDisplayName>(); List<RuleDisplayName> names = new List<RuleDisplayName>();
foreach (var pair in _cachePackRuleTypes) foreach (var pair in _cachePackRuleTypes)
{ {
@@ -229,9 +215,6 @@ namespace YooAsset.Editor
} }
public static List<RuleDisplayName> GetFilterRuleNames() public static List<RuleDisplayName> GetFilterRuleNames()
{ {
if (_setting == null)
LoadSettingData();
List<RuleDisplayName> names = new List<RuleDisplayName>(); List<RuleDisplayName> names = new List<RuleDisplayName>();
foreach (var pair in _cacheFilterRuleTypes) foreach (var pair in _cacheFilterRuleTypes)
{ {

View File

@@ -103,13 +103,16 @@ namespace YooAsset
MainAssetInfo = assetInfo; MainAssetInfo = assetInfo;
// 创建资源包加载器 // 创建资源包加载器
OwnerBundle = impl.CreateOwnerAssetBundleLoader(assetInfo); if (impl != null)
OwnerBundle.Reference(); {
OwnerBundle.AddProvider(this); OwnerBundle = impl.CreateOwnerAssetBundleLoader(assetInfo);
OwnerBundle.Reference();
OwnerBundle.AddProvider(this);
var dependBundles = impl.CreateDependAssetBundleLoaders(assetInfo); var dependBundles = impl.CreateDependAssetBundleLoaders(assetInfo);
DependBundleGroup = new DependAssetBundleGroup(dependBundles); DependBundleGroup = new DependAssetBundleGroup(dependBundles);
DependBundleGroup.Reference(); DependBundleGroup.Reference();
}
} }
/// <summary> /// <summary>

View File

@@ -1,7 +1,7 @@
{ {
"name": "com.tuyoogame.yooasset", "name": "com.tuyoogame.yooasset",
"displayName": "YooAsset", "displayName": "YooAsset",
"version": "1.4.9", "version": "1.4.10",
"unity": "2019.4", "unity": "2019.4",
"description": "unity3d resources management system.", "description": "unity3d resources management system.",
"author": { "author": {

View File

@@ -80,17 +80,17 @@
### 补丁清单 ### 补丁清单
补丁清单文件是上图中以PatchManifest开头命名的文件。 补丁清单文件是上图中以PackageManifest开头命名的文件。
- PatchManifest_DefaultPackage_xxxxxx.hash - PackageManifest_DefaultPackage_xxxxxx.hash
记录了补丁清单文件的哈希值。 记录了补丁清单文件的哈希值。
- PatchManifest_DefaultPackage_xxxxxx.json - PackageManifest_DefaultPackage_xxxxxx.json
该文件为Json文本格式主要用于开发者预览信息。 该文件为Json文本格式主要用于开发者预览信息。
- PatchManifest_DefaultPackage_xxxxxx.bytes - PackageManifest_DefaultPackage_xxxxxx.bytes
该文件为二进制格式,主要用于程序内读取加载。 该文件为二进制格式,主要用于程序内读取加载。

View File

@@ -90,11 +90,10 @@
可寻址规则,规则可以自定义扩展。下面是内置规则: 可寻址规则,规则可以自定义扩展。下面是内置规则:
- AddressByFileName 以文件名为定位地址。 - AddressByFileName 以文件名为定位地址。
- AddressByFilePath 以文件路径为定位地址。
- AddressByGrouperAndFileName 以分组名+文件名为定位地址。 - AddressByGrouperAndFileName 以分组名+文件名为定位地址。
- AddressByFolderAndFileName 以文件夹名+文件名为定位地址。 - AddressByFolderAndFileName 以文件夹名+文件名为定位地址。
````c# ````c#
//自定义扩展范例 //自定义扩展范例
public class AddressByFileName : IAddressRule public class AddressByFileName : IAddressRule
@@ -105,7 +104,7 @@
} }
} }
```` ````
- **PackRule** - **PackRule**
打包规则,规则可以自定义扩展。下面是内置规则: 打包规则,规则可以自定义扩展。下面是内置规则:

View File

@@ -26,15 +26,15 @@ v1.0 代表的是APP版本不是资源版本。在没有更换安装包的情
例如我们游戏的当前APP版本是v1.0那么每次生成的补丁文件全部覆盖到v1.0的目录下即可。 例如我们游戏的当前APP版本是v1.0那么每次生成的补丁文件全部覆盖到v1.0的目录下即可。
下面的示例里一共上传过2次补丁包。第二次上传的补丁包会把第一次的版本记录文件PatchManifest_DefaultPackage.version覆盖掉。当我们想回退资源版本的时候把第一次生成的版本记录文件覆盖到同目录下即可。 下面的示例里一共上传过2次补丁包。第二次上传的补丁包会把第一次的版本记录文件PackageManifest_DefaultPackage.version覆盖掉。当我们想回退资源版本的时候把第一次生成的版本记录文件覆盖到同目录下即可。
```` ````
v1.0(游戏版本) v1.0(游戏版本)
├─PatchManifest_DefaultPackage.version ├─PackageManifest_DefaultPackage.version
├─PatchManifest_DefaultPackage_2023-02-01-654.hash ├─PackageManifest_DefaultPackage_2023-02-01-654.hash
├─PatchManifest_DefaultPackage_2023-02-01-654.bytes ├─PackageManifest_DefaultPackage_2023-02-01-654.bytes
├─PatchManifest_DefaultPackage_2023-02-12-789.hash ├─PackageManifest_DefaultPackage_2023-02-12-789.hash
├─PatchManifest_DefaultPackage_2023-02-12-789.bytes ├─PackageManifest_DefaultPackage_2023-02-12-789.bytes
├─2bb5a28d37dabf27df8bc6a4706b8f80.bundle ├─2bb5a28d37dabf27df8bc6a4706b8f80.bundle
├─2dbea9c3056c8839bc03d80a2aebd105.bundle ├─2dbea9c3056c8839bc03d80a2aebd105.bundle
├─6e8c3003a64ead36a0bd2d5cdebfbcf4.bundle ├─6e8c3003a64ead36a0bd2d5cdebfbcf4.bundle

View File

@@ -7,10 +7,10 @@
YooAssets.Initialize(); YooAssets.Initialize();
// 创建默认的资源包 // 创建默认的资源包
var package = YooAssets.CreateAssetsPackage("DefaultPackage"); var package = YooAssets.CreatePackage("DefaultPackage");
// 设置该资源包为默认的资源包可以使用YooAssets相关加载接口加载该资源包内容。 // 设置该资源包为默认的资源包可以使用YooAssets相关加载接口加载该资源包内容。
YooAssets.SetDefaultAssetsPackage(package); YooAssets.SetDefaultPackage(package);
``` ```
资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。 资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。
@@ -26,7 +26,7 @@ private IEnumerator InitializeYooAsset()
{ {
var initParameters = new EditorSimulateModeParameters(); var initParameters = new EditorSimulateModeParameters();
initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage"); initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage");
yield return defaultPackage.InitializeAsync(initParameters); yield return package.InitializeAsync(initParameters);
} }
```` ````
@@ -40,7 +40,7 @@ private IEnumerator InitializeYooAsset()
private IEnumerator InitializeYooAsset() private IEnumerator InitializeYooAsset()
{ {
var initParameters = new OfflinePlayModeParameters(); var initParameters = new OfflinePlayModeParameters();
yield return defaultPackage.InitializeAsync(initParameters); yield return package.InitializeAsync(initParameters);
} }
```` ````
@@ -65,7 +65,7 @@ private IEnumerator InitializeYooAsset()
initParameters.QueryServices = new QueryStreamingAssetsFileServices(); initParameters.QueryServices = new QueryStreamingAssetsFileServices();
initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android/v1.0"; initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android/v1.0";
initParameters.FallbackHostServer = "http://127.0.0.1/CDN2/Android/v1.0"; initParameters.FallbackHostServer = "http://127.0.0.1/CDN2/Android/v1.0";
yield return defaultPackage.InitializeAsync(initParameters); yield return package.InitializeAsync(initParameters);
} }
// 内置文件查询服务类 // 内置文件查询服务类

View File

@@ -7,9 +7,9 @@
该资源版本可以通过YooAssets提供的接口来更新也可以通过HTTP访问游戏服务器来获取。 该资源版本可以通过YooAssets提供的接口来更新也可以通过HTTP访问游戏服务器来获取。
````c# ````c#
private IEnumerator UpdateStaticVersion() private IEnumerator UpdatePackageVersion()
{ {
var package = YooAssets.GetAssetsPackage("DefaultPackage"); var package = YooAssets.GetPackage("DefaultPackage");
var operation = package.UpdatePackageVersionAsync(); var operation = package.UpdatePackageVersionAsync();
yield return operation; yield return operation;
@@ -32,9 +32,9 @@ private IEnumerator UpdateStaticVersion()
对于联机运行模式,在获取到资源版本号之后,就可以更新资源清单了。 对于联机运行模式,在获取到资源版本号之后,就可以更新资源清单了。
````c# ````c#
private IEnumerator UpdatePatchManifest() private IEnumerator UpdatePackageManifest()
{ {
var package = YooAssets.GetAssetsPackage("DefaultPackage"); var package = YooAssets.GetPackage("DefaultPackage");
var operation = package.UpdatePackageManifestAsync(packageVersion); var operation = package.UpdatePackageManifestAsync(packageVersion);
yield return operation; yield return operation;
@@ -58,11 +58,11 @@ private IEnumerator UpdatePatchManifest()
补丁包下载接口: 补丁包下载接口:
- YooAssets.CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout) - YooAssets.CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
用于下载更新当前资源版本所有的资源包文件。 用于下载更新当前资源版本所有的资源包文件。
- YooAssets.CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) - YooAssets.CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
用于下载更新资源标签指定的资源包文件。 用于下载更新资源标签指定的资源包文件。
@@ -76,8 +76,8 @@ IEnumerator Download()
int downloadingMaxNum = 10; int downloadingMaxNum = 10;
int failedTryAgain = 3; int failedTryAgain = 3;
int timeout = 60; int timeout = 60;
var package = YooAssets.GetAssetsPackage("DefaultPackage"); var package = YooAssets.GetPackage("DefaultPackage");
var downloader = package.CreatePatchDownloader(downloadingMaxNum, failedTryAgain, timeout); var downloader = package.CreateResourceDownloader(downloadingMaxNum, failedTryAgain, timeout);
//没有需要下载的资源 //没有需要下载的资源
if (downloader.TotalDownloadCount == 0) if (downloader.TotalDownloadCount == 0)
@@ -118,7 +118,7 @@ IEnumerator Download()
````c# ````c#
private IEnumerator Start() private IEnumerator Start()
{ {
var package = YooAssets.GetAssetsPackage("DefaultPackage"); var package = YooAssets.GetPackage("DefaultPackage");
var operation = package.UpdatePackageVersionAsync(30); var operation = package.UpdatePackageVersionAsync(30);
yield return operation; yield return operation;
if (operation.Status == EOperationStatus.Succeed) if (operation.Status == EOperationStatus.Succeed)
@@ -131,7 +131,7 @@ private IEnumerator Start()
// 如果获取远端资源版本失败,说明当前网络无连接。 // 如果获取远端资源版本失败,说明当前网络无连接。
// 在正常开始游戏之前,需要验证本地清单内容的完整性。 // 在正常开始游戏之前,需要验证本地清单内容的完整性。
string packageVersion = package.GetPackageVersion(); string packageVersion = package.GetPackageVersion();
var operation = package.PreDownloadPackageAsync(packageVersion); var operation = package.PreDownloadContentAsync(packageVersion);
yield return operation; yield return operation;
if (operation.Status != EOperationStatus.Succeed) if (operation.Status != EOperationStatus.Succeed)
{ {
@@ -142,7 +142,7 @@ private IEnumerator Start()
int downloadingMaxNum = 10; int downloadingMaxNum = 10;
int failedTryAgain = 3; int failedTryAgain = 3;
int timeout = 60; int timeout = 60;
var downloader = operation.CreatePatchDownloader(downloadingMaxNum, failedTryAgain, timeout); var downloader = operation.CreateResourceDownloader(downloadingMaxNum, failedTryAgain, timeout);
if (downloader.TotalDownloadCount > 0) if (downloader.TotalDownloadCount > 0)
{ {
// 资源内容本地并不完整,需要提示玩家联网更新。 // 资源内容本地并不完整,需要提示玩家联网更新。

View File

@@ -2,12 +2,11 @@
**加载方法** **加载方法**
- LoadSceneAsync() 异步加载场景
- LoadAssetSync() 同步加载资源对象 - LoadAssetSync() 同步加载资源对象
- LoadAssetAsync() 异步加载资源对象 - LoadAssetAsync() 异步加载资源对象
- LoadSubAssetsSync() 同步加载子资源对象 - LoadSubAssetsSync() 同步加载子资源对象
- LoadSubAssetsAsync() 异步加载子资源对象 - LoadSubAssetsAsync() 异步加载子资源对象
- LoadSceneSync() 同步加载场景
- LoadSceneAsync() 异步加载场景
- LoadRawFileSync() 同步获取原生文件 - LoadRawFileSync() 同步获取原生文件
- LoadRawFileAsync() 异步获取原生文件 - LoadRawFileAsync() 异步获取原生文件

View File

@@ -13,8 +13,8 @@ private object LoadFunc(string name, string extension, System.Type type, out Des
{ {
method = DestroyMethod.None; //注意这里一定要设置为None method = DestroyMethod.None; //注意这里一定要设置为None
string location = $"Assets/FairyRes/{name}{extension}"; string location = $"Assets/FairyRes/{name}{extension}";
var assetPackage = YooAssets.GetAssetsPackage("DefaultPackage"); var package = YooAssets.GetPackage("DefaultPackage");
var handle = assetPackage.LoadAssetSync(location , type); var handle = package.LoadAssetSync(location , type);
_handles.Add(handle); _handles.Add(handle);
return handle.AssetObject; return handle.AssetObject;
} }
@@ -54,7 +54,7 @@ IEnumerator Start()
YooAssets.Initialize(); YooAssets.Initialize();
// 创建资源包实例 // 创建资源包实例
var package = YooAssets.CreateAssetPackage("DefaultPackage"); var package = YooAssets.CreatePackage("DefaultPackage");
// 初始化资源包 // 初始化资源包
...... ......

View File

@@ -8,5 +8,5 @@
配置说明: 配置说明:
- **Patch Manifest File Name** : 补丁清单文件名称 - **Manifest File Name** : 补丁清单文件名称

View File

@@ -31,7 +31,7 @@ YooAsset可以满足以下任何需求
- **支持可寻址资源定位** - **支持可寻址资源定位**
默认支持相对路径的资源定位,也支持可寻址资源定位,不需要繁琐的过程即可高效的配置寻址路径。 默认支持完整路径的资源定位,也支持可寻址资源定位,不需要繁琐的过程即可高效的配置寻址路径。
- **安全高效的分包方案** - **安全高效的分包方案**