mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-23 09:10:11 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20b0bd26ae | ||
|
|
3b395861d9 | ||
|
|
d5d1f851ab | ||
|
|
c2e2a33af1 | ||
|
|
9a729f921e | ||
|
|
1b75f4b6e9 | ||
|
|
aaab6692c3 | ||
|
|
70fc85e456 | ||
|
|
29358a7b4b | ||
|
|
b1b0563d84 | ||
|
|
21b1e5bee7 | ||
|
|
c02eeef846 | ||
|
|
e84e50708b |
@@ -2,6 +2,58 @@
|
|||||||
|
|
||||||
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.12] - 2023-04-22
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 增加了对WEBGL平台加密选项的检测。
|
||||||
|
|
||||||
|
- 增加了YooAsset/Home Page菜单栏。
|
||||||
|
|
||||||
|
- 增加了鼠标右键创建配置的菜单。
|
||||||
|
|
||||||
|
- 增加了YooAssets.DestroyPackage()方法。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
class YooAssets
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 销毁资源包
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="package">资源包对象</param>
|
||||||
|
public static void DestroyPackage(string packageName);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- UpdatePackageManifestAsync方法增加了新参数autoSaveVersion
|
||||||
|
|
||||||
|
```c#
|
||||||
|
class ResourcePackage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 向网络端请求并更新清单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="packageVersion">更新的包裹版本</param>
|
||||||
|
/// <param name="autoSaveVersion">更新成功后自动保存版本号,作为下次初始化的版本。</param>
|
||||||
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- BuildParameters类增加了新字段。
|
||||||
|
|
||||||
|
可以自定义共享资源文件的打包规则。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
class BuildParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 共享资源的打包规则
|
||||||
|
/// </summary>
|
||||||
|
public IShareAssetPackRule ShareAssetPackRule = null;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## [1.4.11] - 2023-04-14
|
## [1.4.11] - 2023-04-14
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
BuildLogger.Warning($"{buildParameters.BuildMode} pipeline build failed !");
|
BuildLogger.Warning($"{buildParameters.BuildMode} pipeline build failed !");
|
||||||
BuildLogger.Error($"Build task failed : {buildResult.FailedTask}");
|
BuildLogger.Error($"Build task failed : {buildResult.FailedTask}");
|
||||||
BuildLogger.Error($"Build task error : {buildResult.FailedInfo}");
|
BuildLogger.Error(buildResult.ErrorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildResult;
|
return buildResult;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[CreateAssetMenu(fileName = "AssetBundleBuilderSetting", menuName = "YooAsset/Create AssetBundle Builder Settings")]
|
||||||
public class AssetBundleBuilderSetting : ScriptableObject
|
public class AssetBundleBuilderSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
|||||||
public class AssetBundleBuilderWindow : EditorWindow
|
public class AssetBundleBuilderWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||||
public static void ShowExample()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("资源包构建工具", true, WindowsDefine.DockedWindowTypes);
|
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("资源包构建工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
@@ -275,6 +275,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||||
buildParameters.PackageVersion = _buildVersionField.value;
|
buildParameters.PackageVersion = _buildVersionField.value;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
|
buildParameters.ShareAssetPackRule = new DefaultShareAssetPackRule();
|
||||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||||
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算共享资源包的完整包名
|
/// 计算共享资源包的完整包名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CalculateShareBundleName(bool uniqueBundleName, string packageName, string shadersBundleName)
|
public void CalculateShareBundleName(IShareAssetPackRule packRule, bool uniqueBundleName, string packageName, string shadersBundleName)
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.None)
|
if (CollectorType != ECollectorType.None)
|
||||||
return;
|
return;
|
||||||
@@ -173,8 +173,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (_referenceBundleNames.Count > 1)
|
if (_referenceBundleNames.Count > 1)
|
||||||
{
|
{
|
||||||
IPackRule packRule = PackDirectory.StaticPackRule;
|
PackRuleResult packRuleResult = packRule.GetPackRuleResult(AssetPath);
|
||||||
PackRuleResult packRuleResult = packRule.GetPackRuleResult(new PackRuleData(AssetPath));
|
|
||||||
BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
|
BundleName = packRuleResult.GetShareBundleName(packageName, uniqueBundleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -78,7 +78,12 @@ namespace YooAsset.Editor
|
|||||||
public bool VerifyBuildingResult = false;
|
public bool VerifyBuildingResult = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密类
|
/// 共享资源的打包规则
|
||||||
|
/// </summary>
|
||||||
|
public IShareAssetPackRule ShareAssetPackRule = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源的加密接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEncryptionServices EncryptionServices = null;
|
public IEncryptionServices EncryptionServices = null;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建失败的信息
|
/// 构建失败的信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FailedInfo;
|
public string ErrorInfo;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 输出的补丁包目录
|
/// 输出的补丁包目录
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
buildResult.FailedTask = task.GetType().Name;
|
buildResult.FailedTask = task.GetType().Name;
|
||||||
buildResult.FailedInfo = e.ToString();
|
buildResult.ErrorInfo = e.ToString();
|
||||||
buildResult.Success = false;
|
buildResult.Success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
var buildMapContext = CreateBuildMap(buildParameters.BuildMode, buildParameters.ShareAssetPackRule, buildParameters.PackageName);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
BuildLogger.Log("构建内容准备完毕!");
|
BuildLogger.Log("构建内容准备完毕!");
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源构建上下文
|
/// 资源构建上下文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildMapContext CreateBuildMap(EBuildMode buildMode, string packageName)
|
public BuildMapContext CreateBuildMap(EBuildMode buildMode, IShareAssetPackRule packRule, string packageName)
|
||||||
{
|
{
|
||||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfoDic = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> allBuildAssetInfoDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ namespace YooAsset.Editor
|
|||||||
var command = collectResult.Command;
|
var command = collectResult.Command;
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfoDic.Values)
|
||||||
{
|
{
|
||||||
buildAssetInfo.CalculateShareBundleName(command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
|
buildAssetInfo.CalculateShareBundleName(packRule, command.UniqueBundleName, command.PackageName, command.ShadersBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. 移除不参与构建的资源
|
// 9. 移除不参与构建的资源
|
||||||
|
|||||||
@@ -40,6 +40,20 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception("首包资源标签不能为空!");
|
throw new Exception("首包资源标签不能为空!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检测共享资源打包规则
|
||||||
|
if (buildParameters.ShareAssetPackRule == null)
|
||||||
|
throw new Exception("共享资源打包规则不能为空!");
|
||||||
|
|
||||||
|
#if UNITY_WEBGL
|
||||||
|
if (buildParameters.EncryptionServices != null)
|
||||||
|
{
|
||||||
|
if (buildParameters.EncryptionServices.GetType() != typeof(EncryptionNone))
|
||||||
|
{
|
||||||
|
throw new Exception("WebGL平台不支持加密!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// 检测包裹输出目录是否存在
|
// 检测包裹输出目录是否存在
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
if (Directory.Exists(packageOutputDirectory))
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[CreateAssetMenu(fileName = "AssetBundleCollectorSetting", menuName = "YooAsset/Create AssetBundle Collector Settings")]
|
||||||
public class AssetBundleCollectorSetting : ScriptableObject
|
public class AssetBundleCollectorSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
|||||||
public class AssetBundleCollectorWindow : EditorWindow
|
public class AssetBundleCollectorWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Collector", false, 101)]
|
[MenuItem("YooAsset/AssetBundle Collector", false, 101)]
|
||||||
public static void ShowExample()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, WindowsDefine.DockedWindowTypes);
|
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ namespace YooAsset.Editor
|
|||||||
[DisplayName("资源包名: 父类文件夹路径")]
|
[DisplayName("资源包名: 父类文件夹路径")]
|
||||||
public class PackDirectory : IPackRule
|
public class PackDirectory : IPackRule
|
||||||
{
|
{
|
||||||
public static PackDirectory StaticPackRule = new PackDirectory();
|
|
||||||
|
|
||||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class DefaultShareAssetPackRule : IShareAssetPackRule
|
||||||
|
{
|
||||||
|
public PackRuleResult GetPackRuleResult(string assetPath)
|
||||||
|
{
|
||||||
|
string bundleName = Path.GetDirectoryName(assetPath);
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3b8606481370397489cb3aa21e726d9a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 共享资源的打包规则
|
||||||
|
/// </summary>
|
||||||
|
public interface IShareAssetPackRule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取打包规则结果
|
||||||
|
/// </summary>
|
||||||
|
PackRuleResult GetPackRuleResult(string assetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1ed930b0cc1db1742b0a131ca476bd82
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
|||||||
public class AssetBundleDebuggerWindow : EditorWindow
|
public class AssetBundleDebuggerWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
||||||
public static void ShowExample()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, WindowsDefine.DockedWindowTypes);
|
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
wnd.minSize = new Vector2(800, 600);
|
wnd.minSize = new Vector2(800, 600);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
|||||||
public class AssetBundleReporterWindow : EditorWindow
|
public class AssetBundleReporterWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
||||||
public static void ShowExample()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("资源包报告工具", true, WindowsDefine.DockedWindowTypes);
|
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("资源包报告工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
|
|||||||
17
Assets/YooAsset/Editor/HomePage.cs
Normal file
17
Assets/YooAsset/Editor/HomePage.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
internal class HomePageWindow
|
||||||
|
{
|
||||||
|
[MenuItem("YooAsset/Home Page", false, 1)]
|
||||||
|
public static void OpenWindow()
|
||||||
|
{
|
||||||
|
Application.OpenURL("https://www.yooasset.com/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
11
Assets/YooAsset/Editor/HomePage.cs.meta
Normal file
11
Assets/YooAsset/Editor/HomePage.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 901fc6964e7d483428830e2681899473
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
[CreateAssetMenu(fileName = "ShaderVariantCollectorSetting", menuName = "YooAsset/Create ShaderVariant Collector Settings")]
|
||||||
public class ShaderVariantCollectorSetting : ScriptableObject
|
public class ShaderVariantCollectorSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
|||||||
public class ShaderVariantCollectorWindow : EditorWindow
|
public class ShaderVariantCollectorWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/ShaderVariant Collector", false, 201)]
|
[MenuItem("YooAsset/ShaderVariant Collector", false, 201)]
|
||||||
public static void ShowExample()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
ShaderVariantCollectorWindow window = GetWindow<ShaderVariantCollectorWindow>("着色器变种收集工具", true, WindowsDefine.DockedWindowTypes);
|
ShaderVariantCollectorWindow window = GetWindow<ShaderVariantCollectorWindow>("着色器变种收集工具", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
|
|||||||
@@ -187,7 +187,7 @@
|
|||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright 2018-2021 何冠峰
|
Copyright 2018-2021 何冠峰
|
||||||
Copyright 2021-2022 TuYoo Games
|
Copyright 2021-2023 TuYoo Games
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ namespace YooAsset
|
|||||||
private readonly HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly string _packageVersion;
|
private readonly string _packageVersion;
|
||||||
|
private readonly bool _autoSaveVersion;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private LoadCacheManifestOperation _tryLoadCacheManifestOp;
|
private LoadCacheManifestOperation _tryLoadCacheManifestOp;
|
||||||
private LoadCacheManifestOperation _loadCacheManifestOp;
|
private LoadCacheManifestOperation _loadCacheManifestOp;
|
||||||
@@ -76,11 +77,12 @@ namespace YooAsset
|
|||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveVersion, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_packageVersion = packageVersion;
|
_packageVersion = packageVersion;
|
||||||
|
_autoSaveVersion = autoSaveVersion;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
@@ -120,6 +122,8 @@ namespace YooAsset
|
|||||||
if (_tryLoadCacheManifestOp.Status == EOperationStatus.Succeed)
|
if (_tryLoadCacheManifestOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_impl.ActiveManifest = _tryLoadCacheManifestOp.Manifest;
|
_impl.ActiveManifest = _tryLoadCacheManifestOp.Manifest;
|
||||||
|
if (_autoSaveVersion)
|
||||||
|
SavePackageVersion();
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
@@ -166,6 +170,8 @@ namespace YooAsset
|
|||||||
if (_loadCacheManifestOp.Status == EOperationStatus.Succeed)
|
if (_loadCacheManifestOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_impl.ActiveManifest = _loadCacheManifestOp.Manifest;
|
_impl.ActiveManifest = _loadCacheManifestOp.Manifest;
|
||||||
|
if (_autoSaveVersion)
|
||||||
|
SavePackageVersion();
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace YooAsset
|
|||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeUpdatePackageManifestOperation();
|
var operation = new EditorPlayModeUpdatePackageManifestOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
|
|||||||
@@ -111,9 +111,9 @@ namespace YooAsset
|
|||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, timeout);
|
var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, autoSaveVersion, timeout);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace YooAsset
|
|||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new OfflinePlayModeUpdatePackageManifestOperation();
|
var operation = new OfflinePlayModeUpdatePackageManifestOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
|
|||||||
@@ -220,13 +220,13 @@ namespace YooAsset
|
|||||||
/// 向网络端请求并更新清单
|
/// 向网络端请求并更新清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageVersion">更新的包裹版本</param>
|
/// <param name="packageVersion">更新的包裹版本</param>
|
||||||
/// <param name="autoActiveManifest">自动激活清单</param>
|
/// <param name="autoSaveVersion">更新成功后自动保存版本号,作为下次初始化的版本。</param>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60)
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
DebugCheckUpdateManifest();
|
DebugCheckUpdateManifest();
|
||||||
return _playModeServices.UpdatePackageManifestAsync(packageVersion, timeout);
|
return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("YooAsset.Editor")]
|
[assembly: InternalsVisibleTo("YooAsset.Editor")]
|
||||||
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor")]
|
|
||||||
[assembly: InternalsVisibleTo("YooAsset.EditorExtension")]
|
[assembly: InternalsVisibleTo("YooAsset.EditorExtension")]
|
||||||
[assembly: InternalsVisibleTo("YooAsset.RuntimeExtension")]
|
[assembly: InternalsVisibleTo("YooAsset.RuntimeExtension")]
|
||||||
|
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor")]
|
||||||
@@ -21,7 +21,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求并更新清单
|
/// 向网络端请求并更新清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout);
|
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion, int timeout);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 预下载指定版本的包裹内容
|
/// 预下载指定版本的包裹内容
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
[CreateAssetMenu(fileName = "YooAssetSettings", menuName = "YooAsset/Create Settings")]
|
[CreateAssetMenu(fileName = "YooAssetSettings", menuName = "YooAsset/Create YooAsset Settings")]
|
||||||
internal class YooAssetSettings : ScriptableObject
|
internal class YooAssetSettings : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ namespace YooAsset
|
|||||||
if (HasPackage(packageName))
|
if (HasPackage(packageName))
|
||||||
throw new Exception($"Package {packageName} already existed !");
|
throw new Exception($"Package {packageName} already existed !");
|
||||||
|
|
||||||
|
YooLogger.Log($"Create resource package : {packageName}");
|
||||||
ResourcePackage package = new ResourcePackage(packageName);
|
ResourcePackage package = new ResourcePackage(packageName);
|
||||||
_packages.Add(package);
|
_packages.Add(package);
|
||||||
return package;
|
return package;
|
||||||
@@ -136,6 +137,21 @@ namespace YooAsset
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 销毁资源包
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="packageName">资源包名称</param>
|
||||||
|
public static void DestroyPackage(string packageName)
|
||||||
|
{
|
||||||
|
ResourcePackage package = GetPackage(packageName);
|
||||||
|
if (package == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
YooLogger.Log($"Destroy resource package : {packageName}");
|
||||||
|
_packages.Remove(package);
|
||||||
|
package.DestroyPackage();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测资源包是否存在
|
/// 检测资源包是否存在
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -235,10 +251,11 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空沙盒目录
|
/// 清空沙盒目录(需要重启APP)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ClearSandbox()
|
public static void ClearSandbox()
|
||||||
{
|
{
|
||||||
|
YooLogger.Warning("Clear sandbox folder files, Finally, restart the application !");
|
||||||
PersistentHelper.DeleteSandbox();
|
PersistentHelper.DeleteSandbox();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ public class FsmUpdateManifest : IStateNode
|
|||||||
{
|
{
|
||||||
yield return new WaitForSecondsRealtime(0.5f);
|
yield return new WaitForSecondsRealtime(0.5f);
|
||||||
|
|
||||||
|
bool savePackageVersion = true;
|
||||||
var package = YooAssets.GetPackage("DefaultPackage");
|
var package = YooAssets.GetPackage("DefaultPackage");
|
||||||
var operation = package.UpdatePackageManifestAsync(PatchManager.Instance.PackageVersion);
|
var operation = package.UpdatePackageManifestAsync(PatchManager.Instance.PackageVersion, savePackageVersion);
|
||||||
yield return operation;
|
yield return operation;
|
||||||
|
|
||||||
if(operation.Status == EOperationStatus.Succeed)
|
if(operation.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
operation.SavePackageVersion();
|
|
||||||
_machine.ChangeState<FsmCreateDownloader>();
|
_machine.ChangeState<FsmCreateDownloader>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.4.11",
|
"version": "1.4.12",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user