mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 00:11:41 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
366cf3c792 | ||
|
|
21ccd4d29f | ||
|
|
b8ba4219cd | ||
|
|
43da6847ba | ||
|
|
c22c87e16b | ||
|
|
4551dabb39 | ||
|
|
774ad0e5ef | ||
|
|
bd87e982ef | ||
|
|
ecd4973948 | ||
|
|
6dd1eee6c3 | ||
|
|
42703def02 | ||
|
|
afc08d4e46 | ||
|
|
65875b66c2 | ||
|
|
091758022f | ||
|
|
c395a7a750 | ||
|
|
2ab045658b | ||
|
|
c196cd84d3 | ||
|
|
c3c18cd555 | ||
|
|
cb48c672bd | ||
|
|
713073203c | ||
|
|
eafdb8cd31 | ||
|
|
d592fb96a6 |
145
Assets/UniTask.YooAsset~/AsyncOperationBaseExtensions.cs
Normal file
145
Assets/UniTask.YooAsset~/AsyncOperationBaseExtensions.cs
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
using System;
|
||||||
|
using YooAsset;
|
||||||
|
using static Cysharp.Threading.Tasks.Internal.Error;
|
||||||
|
|
||||||
|
namespace Cysharp.Threading.Tasks
|
||||||
|
{
|
||||||
|
public static class AsyncOperationBaseExtensions
|
||||||
|
{
|
||||||
|
public static UniTask.Awaiter GetAwaiter(this AsyncOperationBase handle)
|
||||||
|
{
|
||||||
|
return ToUniTask(handle).GetAwaiter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UniTask ToUniTask(this AsyncOperationBase handle,
|
||||||
|
IProgress<float> progress = null,
|
||||||
|
PlayerLoopTiming timing = PlayerLoopTiming.Update)
|
||||||
|
{
|
||||||
|
ThrowArgumentNullException(handle, nameof(handle));
|
||||||
|
|
||||||
|
if(handle.IsDone)
|
||||||
|
{
|
||||||
|
return UniTask.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UniTask(
|
||||||
|
AsyncOperationBaserConfiguredSource.Create(
|
||||||
|
handle,
|
||||||
|
timing,
|
||||||
|
progress,
|
||||||
|
out var token
|
||||||
|
),
|
||||||
|
token
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sealed class AsyncOperationBaserConfiguredSource : IUniTaskSource,
|
||||||
|
IPlayerLoopItem,
|
||||||
|
ITaskPoolNode<AsyncOperationBaserConfiguredSource>
|
||||||
|
{
|
||||||
|
private static TaskPool<AsyncOperationBaserConfiguredSource> pool;
|
||||||
|
|
||||||
|
private AsyncOperationBaserConfiguredSource nextNode;
|
||||||
|
|
||||||
|
public ref AsyncOperationBaserConfiguredSource NextNode => ref nextNode;
|
||||||
|
|
||||||
|
static AsyncOperationBaserConfiguredSource()
|
||||||
|
{
|
||||||
|
TaskPool.RegisterSizeGetter(typeof(AsyncOperationBaserConfiguredSource), () => pool.Size);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Action<AsyncOperationBase> continuationAction;
|
||||||
|
private AsyncOperationBase handle;
|
||||||
|
private IProgress<float> progress;
|
||||||
|
private bool completed;
|
||||||
|
private UniTaskCompletionSourceCore<AsyncUnit> core;
|
||||||
|
|
||||||
|
AsyncOperationBaserConfiguredSource() { continuationAction = Continuation; }
|
||||||
|
|
||||||
|
public static IUniTaskSource Create(AsyncOperationBase handle,
|
||||||
|
PlayerLoopTiming timing,
|
||||||
|
IProgress<float> progress,
|
||||||
|
out short token)
|
||||||
|
{
|
||||||
|
if(!pool.TryPop(out var result))
|
||||||
|
{
|
||||||
|
result = new AsyncOperationBaserConfiguredSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
result.handle = handle;
|
||||||
|
result.progress = progress;
|
||||||
|
result.completed = false;
|
||||||
|
TaskTracker.TrackActiveTask(result, 3);
|
||||||
|
|
||||||
|
if(progress is not null)
|
||||||
|
{
|
||||||
|
PlayerLoopHelper.AddAction(timing, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
handle.Completed += result.continuationAction;
|
||||||
|
|
||||||
|
token = result.core.Version;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Continuation(AsyncOperationBase _)
|
||||||
|
{
|
||||||
|
handle.Completed -= continuationAction;
|
||||||
|
|
||||||
|
if(completed)
|
||||||
|
{
|
||||||
|
TryReturn();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
completed = true;
|
||||||
|
if(handle.Status == EOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
core.TrySetException(new Exception(handle.Error));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
core.TrySetResult(AsyncUnit.Default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TryReturn()
|
||||||
|
{
|
||||||
|
TaskTracker.RemoveTracking(this);
|
||||||
|
core.Reset();
|
||||||
|
handle = default;
|
||||||
|
progress = default;
|
||||||
|
return pool.TryPush(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UniTaskStatus GetStatus(short token) => core.GetStatus(token);
|
||||||
|
|
||||||
|
public void OnCompleted(Action<object> continuation, object state, short token)
|
||||||
|
{
|
||||||
|
core.OnCompleted(continuation, state, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetResult(short token) { core.GetResult(token); }
|
||||||
|
|
||||||
|
public UniTaskStatus UnsafeGetStatus() => core.UnsafeGetStatus();
|
||||||
|
|
||||||
|
public bool MoveNext()
|
||||||
|
{
|
||||||
|
if(completed)
|
||||||
|
{
|
||||||
|
TryReturn();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!handle.IsDone)
|
||||||
|
{
|
||||||
|
progress?.Report(handle.Progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2cceff5ec1f84bd0a6a9b4ed7719527c
|
||||||
|
timeCreated: 1651978895
|
||||||
7
Assets/UniTask.YooAsset~/README.md.meta
Normal file
7
Assets/UniTask.YooAsset~/README.md.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6375cc739b170490fbc6c38181b2c600
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -2,6 +2,66 @@
|
|||||||
|
|
||||||
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.0.8] - 2022-05-08
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了资源收集器导出配置文件时没有导出公共设置。
|
||||||
|
- 修复了不兼容Unity2018版本的错误。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- AssetBundleGrouper窗口变更为AssetBundleCollector窗口。
|
||||||
|
- **优化了编辑器下模拟运行的初始化速度**。
|
||||||
|
- **优化了资源收集窗口打开时卡顿的问题**。
|
||||||
|
- 资源收集XML配表支持版本兼容。
|
||||||
|
- 资源报告查看窗口支持预览AssetBundle文件内容的功能。
|
||||||
|
- 完善了对UniTask的支持。
|
||||||
|
- YooAssets所有接口支持初始化容错检测。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 异步操作类增加进度查询字段。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
class AsyncOperationBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 处理进度
|
||||||
|
/// </summary>
|
||||||
|
public float Progress { get; protected set; }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 增加开启异步操作的方法。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
/// <summary>
|
||||||
|
/// 开启一个异步操作
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="operation">异步操作对象</param>
|
||||||
|
public static void ProcessOperaiton(GameAsyncOperation operation)
|
||||||
|
```
|
||||||
|
|
||||||
|
- 新增编辑器下模拟模式的初始化参数。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
/// <summary>
|
||||||
|
/// 用于模拟运行的资源清单路径
|
||||||
|
/// 注意:如果路径为空,会自动重新构建补丁清单。
|
||||||
|
/// </summary>
|
||||||
|
public string SimulatePatchManifestPath;
|
||||||
|
````
|
||||||
|
|
||||||
|
- 新增通用的初始化参数。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
/// <summary>
|
||||||
|
/// 资源定位地址大小写不敏感
|
||||||
|
/// </summary>
|
||||||
|
public bool LocationToLower = false;
|
||||||
|
```
|
||||||
|
|
||||||
## [1.0.7] - 2022-05-04
|
## [1.0.7] - 2022-05-04
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ namespace YooAsset.Editor
|
|||||||
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
||||||
if (parameters.BuildMode == EBuildMode.DryRunBuild)
|
if (parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
|
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
|
||||||
else if(parameters.BuildMode == EBuildMode.FastRunBuild)
|
else if(parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
PipelineOutputDirectory += $"_{EBuildMode.FastRunBuild}";
|
PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -53,7 +53,7 @@ namespace YooAsset.Editor
|
|||||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||||
|
|
||||||
if (Parameters.BuildMode == EBuildMode.FastRunBuild)
|
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
}
|
}
|
||||||
@@ -89,9 +89,9 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建的耗时(单位:秒)
|
/// 获取构建的耗时(单位:秒)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int GetBuildingSeconds()
|
public float GetBuildingSeconds()
|
||||||
{
|
{
|
||||||
int seconds = (int)(_buildWatch.ElapsedMilliseconds / 1000);
|
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
||||||
return seconds;
|
return seconds;
|
||||||
}
|
}
|
||||||
public void BeginWatch()
|
public void BeginWatch()
|
||||||
@@ -132,16 +132,16 @@ namespace YooAsset.Editor
|
|||||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||||
};
|
};
|
||||||
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.FastRunBuild)
|
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
BuildRunner.EnableLog = false;
|
BuildRunner.EnableLog = false;
|
||||||
else
|
else
|
||||||
BuildRunner.EnableLog = true;
|
BuildRunner.EnableLog = true;
|
||||||
|
|
||||||
bool succeed = BuildRunner.Run(pipeline, _buildContext);
|
bool succeed = BuildRunner.Run(pipeline, _buildContext);
|
||||||
if (succeed)
|
if (succeed)
|
||||||
Debug.Log($"{buildParameters.BuildMode}模式构建成功!");
|
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||||
else
|
else
|
||||||
Debug.LogWarning($"{buildParameters.BuildMode}模式构建失败!");
|
Debug.LogWarning($"{buildParameters.BuildMode} pipeline build failed !");
|
||||||
return succeed;
|
return succeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildVersion = _buildVersionField.value;
|
buildParameters.BuildVersion = _buildVersionField.value;
|
||||||
buildParameters.BuildinTags = _buildTagsField.value;
|
buildParameters.BuildinTags = _buildTagsField.value;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||||
buildParameters.AppendFileExtension = _appendExtensionToggle.value;
|
buildParameters.AppendFileExtension = _appendExtensionToggle.value;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
buildParameters.CompressOption = (ECompressOption)_compressionField.value;
|
buildParameters.CompressOption = (ECompressOption)_compressionField.value;
|
||||||
@@ -199,9 +199,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private List<Type> GetEncryptionServicesClassTypes()
|
private List<Type> GetEncryptionServicesClassTypes()
|
||||||
{
|
{
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IEncryptionServices>();
|
return EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||||
List<Type> classTypes = collection.ToList();
|
|
||||||
return classTypes;
|
|
||||||
}
|
}
|
||||||
private IEncryptionServices CreateEncryptionServicesInstance()
|
private IEncryptionServices CreateEncryptionServicesInstance()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,32 +1,31 @@
|
|||||||
using System;
|
using UnityEditor;
|
||||||
using UnityEditor;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class AssetBundleRuntimeBuilder
|
public static class AssetBundleSimulateBuilder
|
||||||
{
|
{
|
||||||
private static string _manifestFilePath = string.Empty;
|
private static string _manifestFilePath = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 快速模式构建
|
/// 模拟构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void FastBuild()
|
public static void SimulateBuild()
|
||||||
{
|
{
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||||
BuildParameters buildParameters = new BuildParameters();
|
BuildParameters buildParameters = new BuildParameters();
|
||||||
buildParameters.OutputRoot = defaultOutputRoot;
|
buildParameters.OutputRoot = defaultOutputRoot;
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.FastRunBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
||||||
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||||
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
bool buildResult = builder.Run(buildParameters);
|
bool buildResult = builder.Run(buildParameters);
|
||||||
if (buildResult)
|
if (buildResult)
|
||||||
{
|
{
|
||||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildTarget);
|
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildTarget);
|
||||||
_manifestFilePath = $"{pipelineOutputDirectory}_{EBuildMode.FastRunBuild}/{YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildVersion)}";
|
_manifestFilePath = $"{pipelineOutputDirectory}_{EBuildMode.SimulateBuild}/{YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildVersion)}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -35,9 +34,9 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建的补丁清单文件路径
|
/// 获取构建的补丁清单路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetPatchManifestFilePath()
|
public static string GetPatchManifestPath()
|
||||||
{
|
{
|
||||||
return _manifestFilePath;
|
return _manifestFilePath;
|
||||||
}
|
}
|
||||||
@@ -147,11 +147,11 @@ namespace YooAsset.Editor
|
|||||||
if (IsRawAsset)
|
if (IsRawAsset)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||||
{
|
{
|
||||||
if (IsShaderAsset)
|
if (IsShaderAsset)
|
||||||
{
|
{
|
||||||
string shareBundleName = $"{AssetBundleGrouperSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
string shareBundleName = $"{AssetBundleCollectorSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行资源构建上下文
|
/// 执行资源构建上下文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static BuildMapContext CreateBuildMap()
|
public static BuildMapContext CreateBuildMap(EBuildMode buildMode)
|
||||||
{
|
{
|
||||||
BuildMapContext context = new BuildMapContext();
|
BuildMapContext context = new BuildMapContext();
|
||||||
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
|
||||||
// 1. 检测配置合法性
|
// 1. 检测配置合法性
|
||||||
AssetBundleGrouperSettingData.Setting.CheckConfigError();
|
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||||
|
|
||||||
// 2. 获取所有主动收集的资源
|
// 2. 获取所有主动收集的资源
|
||||||
List<CollectAssetInfo> allCollectAssets = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(buildMode);
|
||||||
|
|
||||||
// 3. 剔除未被引用的依赖资源
|
// 3. 剔除未被引用的依赖资源
|
||||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||||
|
|||||||
@@ -8,6 +8,21 @@ namespace YooAsset.Editor
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReportBundleInfo
|
public class ReportBundleInfo
|
||||||
{
|
{
|
||||||
|
public class FlagsData
|
||||||
|
{
|
||||||
|
public bool IsEncrypted { private set; get; }
|
||||||
|
public bool IsBuildin { private set; get; }
|
||||||
|
public bool IsRawFile { private set; get; }
|
||||||
|
public FlagsData(bool isEncrypted, bool isBuildin, bool isRawFile)
|
||||||
|
{
|
||||||
|
IsEncrypted = isEncrypted;
|
||||||
|
IsBuildin = isBuildin;
|
||||||
|
IsRawFile = isRawFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FlagsData _flagData;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -38,6 +53,26 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Flags;
|
public int Flags;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取标志位的解析数据
|
||||||
|
/// </summary>
|
||||||
|
public FlagsData GetFlagData()
|
||||||
|
{
|
||||||
|
if (_flagData == null)
|
||||||
|
{
|
||||||
|
BitMask32 value = Flags;
|
||||||
|
bool isEncrypted = value.Test(0);
|
||||||
|
bool isBuildin = value.Test(1);
|
||||||
|
bool isRawFile = value.Test(2);
|
||||||
|
_flagData = new FlagsData(isEncrypted, isBuildin, isRawFile);
|
||||||
|
}
|
||||||
|
return _flagData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源分类标签的字符串
|
||||||
|
/// </summary>
|
||||||
public string GetTagsString()
|
public string GetTagsString()
|
||||||
{
|
{
|
||||||
if (Tags != null)
|
if (Tags != null)
|
||||||
@@ -45,5 +80,16 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为原生文件
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRawFile()
|
||||||
|
{
|
||||||
|
if (System.IO.Path.GetExtension(BundleName) == $".{YooAssetSettingsData.Setting.RawFileVariant}")
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,14 +45,22 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 普通日志输出
|
/// 日志输出
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Log(string info)
|
public static void Log(string info)
|
||||||
{
|
{
|
||||||
if (EnableLog)
|
if (EnableLog)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log(info);
|
UnityEngine.Debug.Log(info);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 日志输出
|
||||||
|
/// </summary>
|
||||||
|
public static void Info(string info)
|
||||||
|
{
|
||||||
|
UnityEngine.Debug.Log(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,9 +21,9 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
// 快速构建模式下跳过引擎构建
|
// 模拟构建模式下跳过引擎构建
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.FastRunBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
||||||
|
|||||||
@@ -12,20 +12,30 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
CreateReportFile(buildParameters, buildMapContext);
|
buildParameters.StopWatch();
|
||||||
|
|
||||||
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
|
{
|
||||||
|
CreateReportFile(buildParameters, buildMapContext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float buildSeconds = buildParameters.GetBuildingSeconds();
|
||||||
|
BuildRunner.Info($"Build time consuming {buildSeconds} seconds.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||||
BuildReport buildReport = new BuildReport();
|
BuildReport buildReport = new BuildReport();
|
||||||
buildParameters.StopWatch();
|
|
||||||
|
|
||||||
// 概述信息
|
// 概述信息
|
||||||
{
|
{
|
||||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||||
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
buildReport.Summary.BuildTime = DateTime.Now.ToString();
|
||||||
buildReport.Summary.BuildSeconds = buildParameters.GetBuildingSeconds();
|
buildReport.Summary.BuildSeconds = (int)buildParameters.GetBuildingSeconds();
|
||||||
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
|
||||||
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
|
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
|
||||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||||
@@ -33,8 +43,8 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
||||||
buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
|
buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
|
||||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||||
buildReport.Summary.AutoCollectShaders = AssetBundleGrouperSettingData.Setting.AutoCollectShaders;
|
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
|
||||||
buildReport.Summary.ShadersBundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
|
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
|
||||||
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildMapContext = BuildMapCreater.CreateBuildMap();
|
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
|
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
BuildRunner.Log("构建内容准备完毕!");
|
BuildRunner.Log("构建内容准备完毕!");
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
|
|
||||||
// 快速构建模式下跳过验证
|
// 模拟构建模式下跳过验证
|
||||||
if (buildParametersContext.Parameters.BuildMode == EBuildMode.FastRunBuild)
|
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 验证构建结果
|
// 验证构建结果
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
IncrementalBuild,
|
IncrementalBuild,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 快速构建模式
|
|
||||||
/// </summary>
|
|
||||||
FastRunBuild,
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 演练构建模式
|
/// 演练构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DryRunBuild,
|
DryRunBuild,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 模拟构建模式
|
||||||
|
/// </summary>
|
||||||
|
SimulateBuild,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,13 +51,13 @@ namespace YooAsset.Editor
|
|||||||
if (CollectorType == ECollectorType.None)
|
if (CollectorType == ECollectorType.None)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -74,21 +74,28 @@ namespace YooAsset.Editor
|
|||||||
if (CollectorType == ECollectorType.None)
|
if (CollectorType == ECollectorType.None)
|
||||||
throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}");
|
throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}");
|
||||||
|
|
||||||
if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}");
|
throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}");
|
||||||
|
|
||||||
if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}");
|
throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}");
|
||||||
|
|
||||||
if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(AssetBundleGrouper grouper)
|
public List<CollectAssetInfo> GetAllCollectAssets(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
|
// 注意:模拟构建模式下只收集主资源
|
||||||
|
if (AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild)
|
||||||
|
{
|
||||||
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
|
return new List<CollectAssetInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||||
bool isRawAsset = PackRuleName == nameof(PackRawFile);
|
bool isRawAsset = PackRuleName == nameof(PackRawFile);
|
||||||
|
|
||||||
@@ -97,7 +104,7 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
throw new Exception($"The raw file must be set to {nameof(ECollectorType)}.{ECollectorType.MainAssetCollector} : {CollectPath}");
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(CollectPath))
|
if (string.IsNullOrEmpty(CollectPath))
|
||||||
throw new Exception($"The collect path is null or empty in grouper : {grouper.GrouperName}");
|
throw new Exception($"The collect path is null or empty in group : {group.GroupName}");
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||||
@@ -110,7 +117,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(grouper, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -125,7 +132,7 @@ namespace YooAsset.Editor
|
|||||||
string assetPath = CollectPath;
|
string assetPath = CollectPath;
|
||||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(grouper, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -135,7 +142,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (AssetBundleGrouperSettingData.Setting.EnableAddressable)
|
if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
@@ -155,11 +162,11 @@ namespace YooAsset.Editor
|
|||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectAssetInfo CreateCollectAssetInfo(AssetBundleGrouper grouper, string assetPath, bool isRawAsset)
|
private CollectAssetInfo CreateCollectAssetInfo(AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
||||||
{
|
{
|
||||||
string address = GetAddress(grouper, assetPath);
|
string address = GetAddress(group, assetPath);
|
||||||
string bundleName = GetBundleName(grouper, assetPath);
|
string bundleName = GetBundleName(group, assetPath);
|
||||||
List<string> assetTags = GetAssetTags(grouper);
|
List<string> assetTags = GetAssetTags(group);
|
||||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||||
return collectAssetInfo;
|
return collectAssetInfo;
|
||||||
@@ -186,7 +193,7 @@ namespace YooAsset.Editor
|
|||||||
private bool IsCollectAsset(string assetPath)
|
private bool IsCollectAsset(string assetPath)
|
||||||
{
|
{
|
||||||
// 如果收集全路径着色器
|
// 如果收集全路径着色器
|
||||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||||
{
|
{
|
||||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader))
|
if (assetType == typeof(UnityEngine.Shader))
|
||||||
@@ -194,47 +201,51 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据规则设置过滤资源文件
|
// 根据规则设置过滤资源文件
|
||||||
IFilterRule filterRuleInstance = AssetBundleGrouperSettingData.GetFilterRuleInstance(FilterRuleName);
|
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath));
|
||||||
}
|
}
|
||||||
private string GetAddress(AssetBundleGrouper grouper, string assetPath)
|
private string GetAddress(AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
IAddressRule addressRuleInstance = AssetBundleGrouperSettingData.GetAddressRuleInstance(AddressRuleName);
|
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, grouper.GrouperName));
|
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName));
|
||||||
return adressValue;
|
return adressValue;
|
||||||
}
|
}
|
||||||
private string GetBundleName(AssetBundleGrouper grouper, string assetPath)
|
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
// 如果自动收集所有的着色器
|
// 如果自动收集所有的着色器
|
||||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||||
{
|
{
|
||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader))
|
if (assetType == typeof(UnityEngine.Shader))
|
||||||
{
|
{
|
||||||
string bundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
string bundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据规则设置获取资源包名称
|
// 根据规则设置获取资源包名称
|
||||||
{
|
{
|
||||||
IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName);
|
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName));
|
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
||||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleGrouper grouper)
|
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
List<string> tags = StringUtility.StringToStringList(grouper.AssetTags, ';');
|
List<string> tags = StringUtility.StringToStringList(group.AssetTags, ';');
|
||||||
List<string> temper = StringUtility.StringToStringList(AssetTags, ';');
|
List<string> temper = StringUtility.StringToStringList(AssetTags, ';');
|
||||||
tags.AddRange(temper);
|
tags.AddRange(temper);
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
private List<string> GetAllDependencies(string mainAssetPath)
|
private List<string> GetAllDependencies(string mainAssetPath)
|
||||||
{
|
{
|
||||||
|
// 注意:模拟构建模式下不需要收集依赖资源
|
||||||
|
if(AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild)
|
||||||
|
return new List<string>();
|
||||||
|
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||||
foreach (string assetPath in depends)
|
foreach (string assetPath in depends)
|
||||||
@@ -8,14 +8,18 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleGrouperConfig
|
public class AssetBundleCollectorConfig
|
||||||
{
|
{
|
||||||
public const string XmlShader = "Shader";
|
public const string ConfigVersion = "1.0";
|
||||||
|
|
||||||
|
public const string XmlVersion = "Version";
|
||||||
|
public const string XmlCommon = "Common";
|
||||||
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
public const string XmlAutoCollectShader = "AutoCollectShader";
|
public const string XmlAutoCollectShader = "AutoCollectShader";
|
||||||
public const string XmlShaderBundleName = "ShaderBundleName";
|
public const string XmlShaderBundleName = "ShaderBundleName";
|
||||||
public const string XmlGrouper = "Grouper";
|
public const string XmlGroup = "Group";
|
||||||
public const string XmlGrouperName = "GrouperName";
|
public const string XmlGroupName = "GroupName";
|
||||||
public const string XmlGrouperDesc = "GrouperDesc";
|
public const string XmlGroupDesc = "GroupDesc";
|
||||||
public const string XmlCollector = "Collector";
|
public const string XmlCollector = "Collector";
|
||||||
public const string XmlCollectPath = "CollectPath";
|
public const string XmlCollectPath = "CollectPath";
|
||||||
public const string XmlCollectorType = "CollectType";
|
public const string XmlCollectorType = "CollectType";
|
||||||
@@ -40,43 +44,54 @@ namespace YooAsset.Editor
|
|||||||
xml.Load(filePath);
|
xml.Load(filePath);
|
||||||
XmlElement root = xml.DocumentElement;
|
XmlElement root = xml.DocumentElement;
|
||||||
|
|
||||||
// 读取着色器配置
|
// 读取配置版本
|
||||||
|
string configVersion = root.GetAttribute(XmlVersion);
|
||||||
|
if(configVersion != ConfigVersion)
|
||||||
|
{
|
||||||
|
throw new Exception($"The config version is invalid : {configVersion}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取公共配置
|
||||||
|
bool enableAddressable = false;
|
||||||
bool autoCollectShaders = false;
|
bool autoCollectShaders = false;
|
||||||
string shaderBundleName = string.Empty;
|
string shaderBundleName = string.Empty;
|
||||||
var shaderNodeList = root.GetElementsByTagName(XmlShader);
|
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||||
if (shaderNodeList.Count > 0)
|
if (commonNodeList.Count > 0)
|
||||||
{
|
{
|
||||||
XmlElement shaderElement = shaderNodeList[0] as XmlElement;
|
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||||
if (shaderElement.HasAttribute(XmlAutoCollectShader) == false)
|
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
||||||
throw new Exception($"Not found attribute {XmlAutoCollectShader} in {XmlShader}");
|
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
||||||
if (shaderElement.HasAttribute(XmlShaderBundleName) == false)
|
if (commonElement.HasAttribute(XmlAutoCollectShader) == false)
|
||||||
throw new Exception($"Not found attribute {XmlShaderBundleName} in {XmlShader}");
|
throw new Exception($"Not found attribute {XmlAutoCollectShader} in {XmlCommon}");
|
||||||
|
if (commonElement.HasAttribute(XmlShaderBundleName) == false)
|
||||||
|
throw new Exception($"Not found attribute {XmlShaderBundleName} in {XmlCommon}");
|
||||||
|
|
||||||
autoCollectShaders = shaderElement.GetAttribute(XmlAutoCollectShader) == "True" ? true : false;
|
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
shaderBundleName = shaderElement.GetAttribute(XmlShaderBundleName);
|
autoCollectShaders = commonElement.GetAttribute(XmlAutoCollectShader) == "True" ? true : false;
|
||||||
|
shaderBundleName = commonElement.GetAttribute(XmlShaderBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取分组配置
|
// 读取分组配置
|
||||||
List<AssetBundleGrouper> grouperTemper = new List<AssetBundleGrouper>();
|
List<AssetBundleCollectorGroup> groupTemper = new List<AssetBundleCollectorGroup>();
|
||||||
var grouperNodeList = root.GetElementsByTagName(XmlGrouper);
|
var groupNodeList = root.GetElementsByTagName(XmlGroup);
|
||||||
foreach (var grouperNode in grouperNodeList)
|
foreach (var groupNode in groupNodeList)
|
||||||
{
|
{
|
||||||
XmlElement grouperElement = grouperNode as XmlElement;
|
XmlElement groupElement = groupNode as XmlElement;
|
||||||
if (grouperElement.HasAttribute(XmlGrouperName) == false)
|
if (groupElement.HasAttribute(XmlGroupName) == false)
|
||||||
throw new Exception($"Not found attribute {XmlGrouperName} in {XmlGrouper}");
|
throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
|
||||||
if (grouperElement.HasAttribute(XmlGrouperDesc) == false)
|
if (groupElement.HasAttribute(XmlGroupDesc) == false)
|
||||||
throw new Exception($"Not found attribute {XmlGrouperDesc} in {XmlGrouper}");
|
throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
|
||||||
if (grouperElement.HasAttribute(XmlAssetTags) == false)
|
if (groupElement.HasAttribute(XmlAssetTags) == false)
|
||||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGrouper}");
|
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
|
||||||
|
|
||||||
AssetBundleGrouper grouper = new AssetBundleGrouper();
|
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||||
grouper.GrouperName = grouperElement.GetAttribute(XmlGrouperName);
|
group.GroupName = groupElement.GetAttribute(XmlGroupName);
|
||||||
grouper.GrouperDesc = grouperElement.GetAttribute(XmlGrouperDesc);
|
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
|
||||||
grouper.AssetTags = grouperElement.GetAttribute(XmlAssetTags);
|
group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
|
||||||
grouperTemper.Add(grouper);
|
groupTemper.Add(group);
|
||||||
|
|
||||||
// 读取收集器配置
|
// 读取收集器配置
|
||||||
var collectorNodeList = grouperElement.GetElementsByTagName(XmlCollector);
|
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||||
foreach (var collectorNode in collectorNodeList)
|
foreach (var collectorNode in collectorNodeList)
|
||||||
{
|
{
|
||||||
XmlElement collectorElement = collectorNode as XmlElement;
|
XmlElement collectorElement = collectorNode as XmlElement;
|
||||||
@@ -100,16 +115,17 @@ namespace YooAsset.Editor
|
|||||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags); ;
|
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags); ;
|
||||||
grouper.Collectors.Add(collector);
|
group.Collectors.Add(collector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存配置数据
|
// 保存配置数据
|
||||||
AssetBundleGrouperSettingData.ClearAll();
|
AssetBundleCollectorSettingData.ClearAll();
|
||||||
AssetBundleGrouperSettingData.Setting.AutoCollectShaders = autoCollectShaders;
|
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||||
AssetBundleGrouperSettingData.Setting.ShadersBundleName = shaderBundleName;
|
AssetBundleCollectorSettingData.Setting.AutoCollectShaders = autoCollectShaders;
|
||||||
AssetBundleGrouperSettingData.Setting.Groupers.AddRange(grouperTemper);
|
AssetBundleCollectorSettingData.Setting.ShadersBundleName = shaderBundleName;
|
||||||
AssetBundleGrouperSettingData.SaveFile();
|
AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper);
|
||||||
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
Debug.Log($"导入配置完毕!");
|
Debug.Log($"导入配置完毕!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,22 +146,27 @@ namespace YooAsset.Editor
|
|||||||
xmlDoc.LoadXml(sb.ToString());
|
xmlDoc.LoadXml(sb.ToString());
|
||||||
XmlElement root = xmlDoc.DocumentElement;
|
XmlElement root = xmlDoc.DocumentElement;
|
||||||
|
|
||||||
// 设置着色器配置
|
// 设置配置版本
|
||||||
var shaderElement = xmlDoc.CreateElement(XmlShader);
|
root.SetAttribute(XmlVersion, ConfigVersion);
|
||||||
shaderElement.SetAttribute(XmlAutoCollectShader, AssetBundleGrouperSettingData.Setting.AutoCollectShaders.ToString());
|
|
||||||
shaderElement.SetAttribute(XmlShaderBundleName, AssetBundleGrouperSettingData.Setting.ShadersBundleName);
|
// 设置公共配置
|
||||||
|
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||||
|
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||||
|
commonElement.SetAttribute(XmlAutoCollectShader, AssetBundleCollectorSettingData.Setting.AutoCollectShaders.ToString());
|
||||||
|
commonElement.SetAttribute(XmlShaderBundleName, AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
||||||
|
root.AppendChild(commonElement);
|
||||||
|
|
||||||
// 设置分组配置
|
// 设置分组配置
|
||||||
foreach (var grouper in AssetBundleGrouperSettingData.Setting.Groupers)
|
foreach (var group in AssetBundleCollectorSettingData.Setting.Groups)
|
||||||
{
|
{
|
||||||
var grouperElement = xmlDoc.CreateElement(XmlGrouper);
|
var groupElement = xmlDoc.CreateElement(XmlGroup);
|
||||||
grouperElement.SetAttribute(XmlGrouperName, grouper.GrouperName);
|
groupElement.SetAttribute(XmlGroupName, group.GroupName);
|
||||||
grouperElement.SetAttribute(XmlGrouperDesc, grouper.GrouperDesc);
|
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
|
||||||
grouperElement.SetAttribute(XmlAssetTags, grouper.AssetTags);
|
groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
|
||||||
root.AppendChild(grouperElement);
|
root.AppendChild(groupElement);
|
||||||
|
|
||||||
// 设置收集器配置
|
// 设置收集器配置
|
||||||
foreach (var collector in grouper.Collectors)
|
foreach (var collector in group.Collectors)
|
||||||
{
|
{
|
||||||
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
||||||
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
||||||
@@ -154,7 +175,7 @@ namespace YooAsset.Editor
|
|||||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||||
grouperElement.AppendChild(collectorElement);
|
groupElement.AppendChild(collectorElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8,17 +8,17 @@ using UnityEditor;
|
|||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class AssetBundleGrouper
|
public class AssetBundleCollectorGroup
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组名称
|
/// 分组名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GrouperName = string.Empty;
|
public string GroupName = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组描述
|
/// 分组描述
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GrouperDesc = string.Empty;
|
public string GroupDesc = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源分类标签
|
/// 资源分类标签
|
||||||
@@ -58,12 +58,12 @@ namespace YooAsset.Editor
|
|||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||||
result.Add(assetInfo.AssetPath, assetInfo);
|
result.Add(assetInfo.AssetPath, assetInfo);
|
||||||
else
|
else
|
||||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in grouper : {GrouperName}");
|
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (AssetBundleGrouperSettingData.Setting.EnableAddressable)
|
if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
@@ -74,7 +74,7 @@ namespace YooAsset.Editor
|
|||||||
if (adressTemper.Contains(address) == false)
|
if (adressTemper.Contains(address) == false)
|
||||||
adressTemper.Add(address);
|
adressTemper.Add(address);
|
||||||
else
|
else
|
||||||
throw new Exception($"The address is existed : {address} in grouper : {GrouperName}");
|
throw new Exception($"The address is existed : {address} in group : {GroupName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,10 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleGrouperSetting : ScriptableObject
|
public class AssetBundleCollectorSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
|
public static EBuildMode BuildMode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用可寻址资源定位
|
/// 是否启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -26,7 +28,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组列表
|
/// 分组列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<AssetBundleGrouper> Groupers = new List<AssetBundleGrouper>();
|
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -34,29 +36,31 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckConfigError()
|
public void CheckConfigError()
|
||||||
{
|
{
|
||||||
foreach (var grouper in Groupers)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
grouper.CheckConfigError();
|
group.CheckConfigError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets()
|
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode)
|
||||||
{
|
{
|
||||||
|
BuildMode = buildMode;
|
||||||
|
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var grouper in Groupers)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
var temper = grouper.GetAllCollectAssets();
|
var temper = group.GetAllCollectAssets();
|
||||||
foreach (var assetInfo in temper)
|
foreach (var assetInfo in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||||
result.Add(assetInfo.AssetPath, assetInfo);
|
result.Add(assetInfo.AssetPath, assetInfo);
|
||||||
else
|
else
|
||||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in grouper setting.");
|
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group setting.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +76,7 @@ namespace YooAsset.Editor
|
|||||||
if (adressTemper.Contains(address) == false)
|
if (adressTemper.Contains(address) == false)
|
||||||
adressTemper.Add(address);
|
adressTemper.Add(address);
|
||||||
else
|
else
|
||||||
throw new Exception($"The address is existed : {address} in grouper setting.");
|
throw new Exception($"The address is existed : {address} in group setting.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ using UnityEditor;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleGrouperSettingData
|
public class AssetBundleCollectorSettingData
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
||||||
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
||||||
@@ -24,8 +24,8 @@ namespace YooAsset.Editor
|
|||||||
public static bool IsDirty { private set; get; } = false;
|
public static bool IsDirty { private set; get; } = false;
|
||||||
|
|
||||||
|
|
||||||
private static AssetBundleGrouperSetting _setting = null;
|
private static AssetBundleCollectorSetting _setting = null;
|
||||||
public static AssetBundleGrouperSetting Setting
|
public static AssetBundleCollectorSetting Setting
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -106,12 +106,12 @@ namespace YooAsset.Editor
|
|||||||
private static void LoadSettingData()
|
private static void LoadSettingData()
|
||||||
{
|
{
|
||||||
// 加载配置文件
|
// 加载配置文件
|
||||||
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleGrouperSetting)}.asset";
|
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleCollectorSetting)}.asset";
|
||||||
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleGrouperSetting>(settingFilePath);
|
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleCollectorSetting>(settingFilePath);
|
||||||
if (_setting == null)
|
if (_setting == null)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Create new {nameof(AssetBundleGrouperSetting)}.asset : {settingFilePath}");
|
Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {settingFilePath}");
|
||||||
_setting = ScriptableObject.CreateInstance<AssetBundleGrouperSetting>();
|
_setting = ScriptableObject.CreateInstance<AssetBundleCollectorSetting>();
|
||||||
EditorTools.CreateFileDirectory(settingFilePath);
|
EditorTools.CreateFileDirectory(settingFilePath);
|
||||||
AssetDatabase.CreateAsset(Setting, settingFilePath);
|
AssetDatabase.CreateAsset(Setting, settingFilePath);
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
@@ -119,7 +119,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log($"Load {nameof(AssetBundleGrouperSetting)}.asset ok");
|
Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPackRule
|
// IPackRule
|
||||||
@@ -135,12 +135,11 @@ namespace YooAsset.Editor
|
|||||||
typeof(PackDirectory),
|
typeof(PackDirectory),
|
||||||
typeof(PackTopDirectory),
|
typeof(PackTopDirectory),
|
||||||
typeof(PackCollector),
|
typeof(PackCollector),
|
||||||
typeof(PackGrouper),
|
typeof(PackGroup),
|
||||||
typeof(PackRawFile),
|
typeof(PackRawFile),
|
||||||
};
|
};
|
||||||
|
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IPackRule>();
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
||||||
var customTypes = collection.ToList();
|
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -165,8 +164,7 @@ namespace YooAsset.Editor
|
|||||||
typeof(CollectSprite)
|
typeof(CollectSprite)
|
||||||
};
|
};
|
||||||
|
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IFilterRule>();
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IFilterRule));
|
||||||
var customTypes = collection.ToList();
|
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -187,11 +185,10 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
typeof(AddressByFileName),
|
typeof(AddressByFileName),
|
||||||
typeof(AddressByCollectorAndFileName),
|
typeof(AddressByCollectorAndFileName),
|
||||||
typeof(AddressByGrouperAndFileName)
|
typeof(AddressByGroupAndFileName)
|
||||||
};
|
};
|
||||||
|
|
||||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IAddressRule>();
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
||||||
var customTypes = collection.ToList();
|
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -212,7 +209,7 @@ namespace YooAsset.Editor
|
|||||||
IsDirty = false;
|
IsDirty = false;
|
||||||
EditorUtility.SetDirty(Setting);
|
EditorUtility.SetDirty(Setting);
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
Debug.Log($"{nameof(AssetBundleGrouperSetting)}.asset is saved!");
|
Debug.Log($"{nameof(AssetBundleCollectorSetting)}.asset is saved!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +220,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
Setting.AutoCollectShaders = false;
|
Setting.AutoCollectShaders = false;
|
||||||
Setting.ShadersBundleName = string.Empty;
|
Setting.ShadersBundleName = string.Empty;
|
||||||
Setting.Groupers.Clear();
|
Setting.Groups.Clear();
|
||||||
SaveFile();
|
SaveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,43 +293,43 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 资源分组编辑相关
|
// 资源分组编辑相关
|
||||||
public static void CreateGrouper(string grouperName)
|
public static void CreateGroup(string groupName)
|
||||||
{
|
{
|
||||||
AssetBundleGrouper grouper = new AssetBundleGrouper();
|
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||||
grouper.GrouperName = grouperName;
|
group.GroupName = groupName;
|
||||||
Setting.Groupers.Add(grouper);
|
Setting.Groups.Add(group);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
public static void RemoveGrouper(AssetBundleGrouper grouper)
|
public static void RemoveGroup(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
if (Setting.Groupers.Remove(grouper))
|
if (Setting.Groups.Remove(group))
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Failed remove grouper : {grouper.GrouperName}");
|
Debug.LogWarning($"Failed remove group : {group.GroupName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void ModifyGrouper(AssetBundleGrouper grouper)
|
public static void ModifyGroup(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
if (grouper != null)
|
if (group != null)
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源收集器编辑相关
|
// 资源收集器编辑相关
|
||||||
public static void CreateCollector(AssetBundleGrouper grouper, string collectPath)
|
public static void CreateCollector(AssetBundleCollectorGroup group, string collectPath)
|
||||||
{
|
{
|
||||||
AssetBundleCollector collector = new AssetBundleCollector();
|
AssetBundleCollector collector = new AssetBundleCollector();
|
||||||
collector.CollectPath = collectPath;
|
collector.CollectPath = collectPath;
|
||||||
grouper.Collectors.Add(collector);
|
group.Collectors.Add(collector);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
public static void RemoveCollector(AssetBundleGrouper grouper, AssetBundleCollector collector)
|
public static void RemoveCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||||
{
|
{
|
||||||
if (grouper.Collectors.Remove(collector))
|
if (group.Collectors.Remove(collector))
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
@@ -341,9 +338,9 @@ namespace YooAsset.Editor
|
|||||||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void ModifyCollector(AssetBundleGrouper grouper, AssetBundleCollector collector)
|
public static void ModifyCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||||
{
|
{
|
||||||
if (grouper != null && collector != null)
|
if (group != null && collector != null)
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
@@ -9,12 +9,12 @@ using UnityEngine.UIElements;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleGrouperWindow : EditorWindow
|
public class AssetBundleCollectorWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Grouper", false, 101)]
|
[MenuItem("YooAsset/AssetBundle Collector", false, 101)]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
AssetBundleGrouperWindow window = GetWindow<AssetBundleGrouperWindow>("资源包分组工具", true, EditorDefine.DockedWindowTypes);
|
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, EditorDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,15 +22,15 @@ namespace YooAsset.Editor
|
|||||||
private List<string> _addressRuleList;
|
private List<string> _addressRuleList;
|
||||||
private List<string> _packRuleList;
|
private List<string> _packRuleList;
|
||||||
private List<string> _filterRuleList;
|
private List<string> _filterRuleList;
|
||||||
private ListView _grouperListView;
|
private ListView _groupListView;
|
||||||
private ScrollView _collectorScrollView;
|
private ScrollView _collectorScrollView;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
private Toggle _autoCollectShaderToogle;
|
private Toggle _autoCollectShaderToogle;
|
||||||
private TextField _shaderBundleNameTxt;
|
private TextField _shaderBundleNameTxt;
|
||||||
private TextField _grouperNameTxt;
|
private TextField _groupNameTxt;
|
||||||
private TextField _grouperDescTxt;
|
private TextField _groupDescTxt;
|
||||||
private TextField _grouperAssetTagsTxt;
|
private TextField _groupAssetTagsTxt;
|
||||||
private VisualElement _grouperContainer;
|
private VisualElement _groupContainer;
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
@@ -45,17 +45,17 @@ namespace YooAsset.Editor
|
|||||||
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||||
$"{nameof(ECollectorType.DependAssetCollector)}"
|
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||||
};
|
};
|
||||||
_addressRuleList = AssetBundleGrouperSettingData.GetAddressRuleNames();
|
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||||
_packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames();
|
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||||
_filterRuleList = AssetBundleGrouperSettingData.GetFilterRuleNames();
|
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
string rootPath = EditorTools.GetYooAssetSourcePath();
|
string rootPath = EditorTools.GetYooAssetSourcePath();
|
||||||
string uxml = $"{rootPath}/Editor/AssetBundleGrouper/{nameof(AssetBundleGrouperWindow)}.uxml";
|
string uxml = $"{rootPath}/Editor/AssetBundleCollector/{nameof(AssetBundleCollectorWindow)}.uxml";
|
||||||
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
|
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
{
|
{
|
||||||
Debug.LogError($"Not found {nameof(AssetBundleGrouperWindow)}.uxml : {uxml}");
|
Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml : {uxml}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
visualAsset.CloneTree(root);
|
visualAsset.CloneTree(root);
|
||||||
@@ -72,75 +72,75 @@ namespace YooAsset.Editor
|
|||||||
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
||||||
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleGrouperSettingData.ModifyAddressable(evt.newValue);
|
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||||
});
|
});
|
||||||
_autoCollectShaderToogle = root.Q<Toggle>("AutoCollectShader");
|
_autoCollectShaderToogle = root.Q<Toggle>("AutoCollectShader");
|
||||||
_autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
|
_autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleGrouperSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
AssetBundleCollectorSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
||||||
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
||||||
});
|
});
|
||||||
_shaderBundleNameTxt = root.Q<TextField>("ShaderBundleName");
|
_shaderBundleNameTxt = root.Q<TextField>("ShaderBundleName");
|
||||||
_shaderBundleNameTxt.RegisterValueChangedCallback(evt =>
|
_shaderBundleNameTxt.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleGrouperSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue);
|
AssetBundleCollectorSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 分组列表相关
|
// 分组列表相关
|
||||||
_grouperListView = root.Q<ListView>("GrouperListView");
|
_groupListView = root.Q<ListView>("GroupListView");
|
||||||
_grouperListView.makeItem = MakeGrouperListViewItem;
|
_groupListView.makeItem = MakeGroupListViewItem;
|
||||||
_grouperListView.bindItem = BindGrouperListViewItem;
|
_groupListView.bindItem = BindGroupListViewItem;
|
||||||
#if UNITY_2020_1_OR_NEWER
|
#if UNITY_2020_1_OR_NEWER
|
||||||
_grouperListView.onSelectionChange += GrouperListView_onSelectionChange;
|
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
|
||||||
#else
|
#else
|
||||||
_grouperListView.onSelectionChanged += GrouperListView_onSelectionChange;
|
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 分组添加删除按钮
|
// 分组添加删除按钮
|
||||||
var grouperAddContainer = root.Q("GrouperAddContainer");
|
var groupAddContainer = root.Q("GroupAddContainer");
|
||||||
{
|
{
|
||||||
var addBtn = grouperAddContainer.Q<Button>("AddBtn");
|
var addBtn = groupAddContainer.Q<Button>("AddBtn");
|
||||||
addBtn.clicked += AddGrouperBtn_clicked;
|
addBtn.clicked += AddGroupBtn_clicked;
|
||||||
var removeBtn = grouperAddContainer.Q<Button>("RemoveBtn");
|
var removeBtn = groupAddContainer.Q<Button>("RemoveBtn");
|
||||||
removeBtn.clicked += RemoveGrouperBtn_clicked;
|
removeBtn.clicked += RemoveGroupBtn_clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分组容器
|
// 分组容器
|
||||||
_grouperContainer = root.Q("GrouperContainer");
|
_groupContainer = root.Q("GroupContainer");
|
||||||
|
|
||||||
// 分组名称
|
// 分组名称
|
||||||
_grouperNameTxt = root.Q<TextField>("GrouperName");
|
_groupNameTxt = root.Q<TextField>("GroupName");
|
||||||
_grouperNameTxt.RegisterValueChangedCallback(evt =>
|
_groupNameTxt.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectGrouper != null)
|
if (selectGroup != null)
|
||||||
{
|
{
|
||||||
selectGrouper.GrouperName = evt.newValue;
|
selectGroup.GroupName = evt.newValue;
|
||||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 分组备注
|
// 分组备注
|
||||||
_grouperDescTxt = root.Q<TextField>("GrouperDesc");
|
_groupDescTxt = root.Q<TextField>("GroupDesc");
|
||||||
_grouperDescTxt.RegisterValueChangedCallback(evt =>
|
_groupDescTxt.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectGrouper != null)
|
if (selectGroup != null)
|
||||||
{
|
{
|
||||||
selectGrouper.GrouperDesc = evt.newValue;
|
selectGroup.GroupDesc = evt.newValue;
|
||||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 分组的资源标签
|
// 分组的资源标签
|
||||||
_grouperAssetTagsTxt = root.Q<TextField>("GrouperAssetTags");
|
_groupAssetTagsTxt = root.Q<TextField>("GroupAssetTags");
|
||||||
_grouperAssetTagsTxt.RegisterValueChangedCallback(evt =>
|
_groupAssetTagsTxt.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectGrouper != null)
|
if (selectGroup != null)
|
||||||
{
|
{
|
||||||
selectGrouper.AssetTags = evt.newValue;
|
selectGroup.AssetTags = evt.newValue;
|
||||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -166,26 +166,26 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
if (AssetBundleGrouperSettingData.IsDirty)
|
if (AssetBundleCollectorSettingData.IsDirty)
|
||||||
AssetBundleGrouperSettingData.SaveFile();
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshWindow()
|
private void RefreshWindow()
|
||||||
{
|
{
|
||||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.EnableAddressable);
|
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
||||||
_autoCollectShaderToogle.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.AutoCollectShaders);
|
_autoCollectShaderToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
||||||
_shaderBundleNameTxt.SetEnabled(AssetBundleGrouperSettingData.Setting.AutoCollectShaders);
|
_shaderBundleNameTxt.SetEnabled(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
||||||
_shaderBundleNameTxt.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.ShadersBundleName);
|
_shaderBundleNameTxt.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
||||||
_grouperContainer.visible = false;
|
_groupContainer.visible = false;
|
||||||
|
|
||||||
FillGrouperViewData();
|
FillGroupViewData();
|
||||||
}
|
}
|
||||||
private void ExportBtn_clicked()
|
private void ExportBtn_clicked()
|
||||||
{
|
{
|
||||||
string resultPath = EditorTools.OpenFolderPanel("Export XML", "Assets/");
|
string resultPath = EditorTools.OpenFolderPanel("Export XML", "Assets/");
|
||||||
if (resultPath != null)
|
if (resultPath != null)
|
||||||
{
|
{
|
||||||
AssetBundleGrouperConfig.ExportXmlConfig($"{resultPath}/{nameof(AssetBundleGrouperConfig)}.xml");
|
AssetBundleCollectorConfig.ExportXmlConfig($"{resultPath}/{nameof(AssetBundleCollectorConfig)}.xml");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ImportBtn_clicked()
|
private void ImportBtn_clicked()
|
||||||
@@ -193,20 +193,20 @@ namespace YooAsset.Editor
|
|||||||
string resultPath = EditorTools.OpenFilePath("Import XML", "Assets/", "xml");
|
string resultPath = EditorTools.OpenFilePath("Import XML", "Assets/", "xml");
|
||||||
if (resultPath != null)
|
if (resultPath != null)
|
||||||
{
|
{
|
||||||
AssetBundleGrouperConfig.ImportXmlConfig(resultPath);
|
AssetBundleCollectorConfig.ImportXmlConfig(resultPath);
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分组列表相关
|
// 分组列表相关
|
||||||
private void FillGrouperViewData()
|
private void FillGroupViewData()
|
||||||
{
|
{
|
||||||
_grouperListView.Clear();
|
_groupListView.Clear();
|
||||||
_grouperListView.ClearSelection();
|
_groupListView.ClearSelection();
|
||||||
_grouperListView.itemsSource = AssetBundleGrouperSettingData.Setting.Groupers;
|
_groupListView.itemsSource = AssetBundleCollectorSettingData.Setting.Groups;
|
||||||
_grouperListView.Rebuild();
|
_groupListView.Rebuild();
|
||||||
}
|
}
|
||||||
private VisualElement MakeGrouperListViewItem()
|
private VisualElement MakeGroupListViewItem()
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
VisualElement element = new VisualElement();
|
||||||
|
|
||||||
@@ -221,57 +221,57 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
private void BindGrouperListViewItem(VisualElement element, int index)
|
private void BindGroupListViewItem(VisualElement element, int index)
|
||||||
{
|
{
|
||||||
var grouper = AssetBundleGrouperSettingData.Setting.Groupers[index];
|
var group = AssetBundleCollectorSettingData.Setting.Groups[index];
|
||||||
|
|
||||||
// Grouper Name
|
// Group Name
|
||||||
var textField1 = element.Q<Label>("Label1");
|
var textField1 = element.Q<Label>("Label1");
|
||||||
if (string.IsNullOrEmpty(grouper.GrouperDesc))
|
if (string.IsNullOrEmpty(group.GroupDesc))
|
||||||
textField1.text = grouper.GrouperName;
|
textField1.text = group.GroupName;
|
||||||
else
|
else
|
||||||
textField1.text = $"{grouper.GrouperName} ({grouper.GrouperDesc})";
|
textField1.text = $"{group.GroupName} ({group.GroupDesc})";
|
||||||
}
|
}
|
||||||
private void GrouperListView_onSelectionChange(IEnumerable<object> objs)
|
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
{
|
{
|
||||||
FillCollectorViewData();
|
FillCollectorViewData();
|
||||||
}
|
}
|
||||||
private void AddGrouperBtn_clicked()
|
private void AddGroupBtn_clicked()
|
||||||
{
|
{
|
||||||
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset AddGrouper");
|
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset AddGroup");
|
||||||
AssetBundleGrouperSettingData.CreateGrouper("Default Grouper");
|
AssetBundleCollectorSettingData.CreateGroup("Default Group");
|
||||||
FillGrouperViewData();
|
FillGroupViewData();
|
||||||
}
|
}
|
||||||
private void RemoveGrouperBtn_clicked()
|
private void RemoveGroupBtn_clicked()
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectGrouper == null)
|
if (selectGroup == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset RemoveGrouper");
|
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset RemoveGroup");
|
||||||
|
|
||||||
AssetBundleGrouperSettingData.RemoveGrouper(selectGrouper);
|
AssetBundleCollectorSettingData.RemoveGroup(selectGroup);
|
||||||
FillGrouperViewData();
|
FillGroupViewData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收集列表相关
|
// 收集列表相关
|
||||||
private void FillCollectorViewData()
|
private void FillCollectorViewData()
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectGrouper == null)
|
if (selectGroup == null)
|
||||||
{
|
{
|
||||||
_grouperContainer.visible = false;
|
_groupContainer.visible = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_grouperContainer.visible = true;
|
_groupContainer.visible = true;
|
||||||
_grouperNameTxt.SetValueWithoutNotify(selectGrouper.GrouperName);
|
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
|
||||||
_grouperDescTxt.SetValueWithoutNotify(selectGrouper.GrouperDesc);
|
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
|
||||||
_grouperAssetTagsTxt.SetValueWithoutNotify(selectGrouper.AssetTags);
|
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
|
||||||
|
|
||||||
// 填充数据
|
// 填充数据
|
||||||
_collectorScrollView.Clear();
|
_collectorScrollView.Clear();
|
||||||
for (int i = 0; i < selectGrouper.Collectors.Count; i++)
|
for (int i = 0; i < selectGroup.Collectors.Count; i++)
|
||||||
{
|
{
|
||||||
VisualElement element = MakeCollectorListViewItem();
|
VisualElement element = MakeCollectorListViewItem();
|
||||||
BindCollectorListViewItem(element, i);
|
BindCollectorListViewItem(element, i);
|
||||||
@@ -391,18 +391,24 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private void BindCollectorListViewItem(VisualElement element, int index)
|
private void BindCollectorListViewItem(VisualElement element, int index)
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectGrouper == null)
|
if (selectGroup == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var collector = selectGrouper.Collectors[index];
|
var collector = selectGroup.Collectors[index];
|
||||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||||
if (collectObject != null)
|
if (collectObject != null)
|
||||||
collectObject.name = collector.CollectPath;
|
collectObject.name = collector.CollectPath;
|
||||||
|
|
||||||
// Foldout
|
// Foldout
|
||||||
var foldout = element.Q<Foldout>("Foldout1");
|
var foldout = element.Q<Foldout>("Foldout1");
|
||||||
RefreshFoldout(foldout, selectGrouper, collector);
|
foldout.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
if (evt.newValue)
|
||||||
|
RefreshFoldout(foldout, selectGroup, collector);
|
||||||
|
else
|
||||||
|
foldout.Clear();
|
||||||
|
});
|
||||||
|
|
||||||
// Remove Button
|
// Remove Button
|
||||||
var removeBtn = element.Q<Button>("Button1");
|
var removeBtn = element.Q<Button>("Button1");
|
||||||
@@ -418,8 +424,11 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||||
objectField1.value.name = collector.CollectPath;
|
objectField1.value.name = collector.CollectPath;
|
||||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
RefreshFoldout(foldout, selectGrouper, collector);
|
if (foldout.value)
|
||||||
|
{
|
||||||
|
RefreshFoldout(foldout, selectGroup, collector);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Collector Type
|
// Collector Type
|
||||||
@@ -428,8 +437,11 @@ namespace YooAsset.Editor
|
|||||||
popupField0.RegisterValueChangedCallback(evt =>
|
popupField0.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(evt.newValue);
|
collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(evt.newValue);
|
||||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
RefreshFoldout(foldout, selectGrouper, collector);
|
if (foldout.value)
|
||||||
|
{
|
||||||
|
RefreshFoldout(foldout, selectGroup, collector);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Address Rule
|
// Address Rule
|
||||||
@@ -440,8 +452,11 @@ namespace YooAsset.Editor
|
|||||||
popupField1.RegisterValueChangedCallback(evt =>
|
popupField1.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
collector.AddressRuleName = evt.newValue;
|
collector.AddressRuleName = evt.newValue;
|
||||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
RefreshFoldout(foldout, selectGrouper, collector);
|
if (foldout.value)
|
||||||
|
{
|
||||||
|
RefreshFoldout(foldout, selectGroup, collector);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,8 +466,11 @@ namespace YooAsset.Editor
|
|||||||
popupField2.RegisterValueChangedCallback(evt =>
|
popupField2.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
collector.PackRuleName = evt.newValue;
|
collector.PackRuleName = evt.newValue;
|
||||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
RefreshFoldout(foldout, selectGrouper, collector);
|
if (foldout.value)
|
||||||
|
{
|
||||||
|
RefreshFoldout(foldout, selectGroup, collector);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter Rule
|
// Filter Rule
|
||||||
@@ -461,8 +479,11 @@ namespace YooAsset.Editor
|
|||||||
popupField3.RegisterValueChangedCallback(evt =>
|
popupField3.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
collector.FilterRuleName = evt.newValue;
|
collector.FilterRuleName = evt.newValue;
|
||||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
RefreshFoldout(foldout, selectGrouper, collector);
|
if (foldout.value)
|
||||||
|
{
|
||||||
|
RefreshFoldout(foldout, selectGroup, collector);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
@@ -471,17 +492,17 @@ namespace YooAsset.Editor
|
|||||||
textFiled1.RegisterValueChangedCallback(evt =>
|
textFiled1.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
collector.AssetTags = evt.newValue;
|
collector.AssetTags = evt.newValue;
|
||||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void RefreshFoldout(Foldout foldout, AssetBundleGrouper grouper, AssetBundleCollector collector)
|
private void RefreshFoldout(Foldout foldout, AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||||
{
|
{
|
||||||
// 清空旧元素
|
// 清空旧元素
|
||||||
foldout.Clear();
|
foldout.Clear();
|
||||||
|
|
||||||
if (collector.IsValid() == false)
|
if (collector.IsValid() == false)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in grouper : {grouper.GrouperName}");
|
Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in group : {group.GroupName}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +512,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(grouper);
|
collectAssetInfos = collector.GetAllCollectAssets(group);
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
@@ -509,8 +530,8 @@ namespace YooAsset.Editor
|
|||||||
string showInfo = collectAssetInfo.AssetPath;
|
string showInfo = collectAssetInfo.AssetPath;
|
||||||
if (_enableAddressableToogle.value)
|
if (_enableAddressableToogle.value)
|
||||||
{
|
{
|
||||||
IAddressRule instance = AssetBundleGrouperSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, grouper.GrouperName);
|
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName);
|
||||||
string addressValue = instance.GetAssetAddress(ruleData);
|
string addressValue = instance.GetAssetAddress(ruleData);
|
||||||
showInfo = $"[{addressValue}] {showInfo}";
|
showInfo = $"[{addressValue}] {showInfo}";
|
||||||
}
|
}
|
||||||
@@ -527,21 +548,21 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private void AddCollectorBtn_clicked()
|
private void AddCollectorBtn_clicked()
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectGrouper == null)
|
if (selectGroup == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AssetBundleGrouperSettingData.CreateCollector(selectGrouper, string.Empty);
|
AssetBundleCollectorSettingData.CreateCollector(selectGroup, string.Empty);
|
||||||
FillCollectorViewData();
|
FillCollectorViewData();
|
||||||
}
|
}
|
||||||
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)
|
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||||
if (selectGrouper == null)
|
if (selectGroup == null)
|
||||||
return;
|
return;
|
||||||
if (selectCollector == null)
|
if (selectCollector == null)
|
||||||
return;
|
return;
|
||||||
AssetBundleGrouperSettingData.RemoveCollector(selectGrouper, selectCollector);
|
AssetBundleCollectorSettingData.RemoveCollector(selectGroup, selectCollector);
|
||||||
FillCollectorViewData();
|
FillCollectorViewData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||||
<ui:VisualElement name="LeftContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="LeftContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
<ui:ListView focusable="true" name="GrouperListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||||
<ui:VisualElement name="GrouperAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShader" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShader" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Shader Bundle Name" name="ShaderBundleName" style="flex-grow: 1; -unity-text-align: middle-left;" />
|
<ui:TextField picking-mode="Ignore" label="Shader Bundle Name" name="ShaderBundleName" style="flex-grow: 1; -unity-text-align: middle-left;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="GrouperContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="GroupContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
<ui:TextField picking-mode="Ignore" label="Grouper Name" name="GrouperName" />
|
<ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Grouper Desc" name="GrouperDesc" />
|
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Grouper Asset Tags" name="GrouperAssetTags" />
|
<ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" />
|
||||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
@@ -16,12 +16,12 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以组名+文件名为定位地址
|
/// 以组名+文件名为定位地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AddressByGrouperAndFileName : IAddressRule
|
public class AddressByGroupAndFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||||
return $"{data.GrouperName}_{fileName}";
|
return $"{data.GroupName}_{fileName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,11 +78,11 @@ namespace YooAsset.Editor
|
|||||||
/// 以分组名称作为资源包名
|
/// 以分组名称作为资源包名
|
||||||
/// 注意:收集的所有文件打进一个资源包
|
/// 注意:收集的所有文件打进一个资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PackGrouper : IPackRule
|
public class PackGroup : IPackRule
|
||||||
{
|
{
|
||||||
string IPackRule.GetBundleName(PackRuleData data)
|
string IPackRule.GetBundleName(PackRuleData data)
|
||||||
{
|
{
|
||||||
return data.GrouperName;
|
return data.GroupName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5,13 +5,13 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
public string CollectPath;
|
public string CollectPath;
|
||||||
public string GrouperName;
|
public string GroupName;
|
||||||
|
|
||||||
public AddressRuleData(string assetPath, string collectPath, string grouperName)
|
public AddressRuleData(string assetPath, string collectPath, string groupName)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = collectPath;
|
CollectPath = collectPath;
|
||||||
GrouperName = grouperName;
|
GroupName = groupName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5,19 +5,19 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
public string CollectPath;
|
public string CollectPath;
|
||||||
public string GrouperName;
|
public string GroupName;
|
||||||
|
|
||||||
public PackRuleData(string assetPath)
|
public PackRuleData(string assetPath)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = string.Empty;
|
CollectPath = string.Empty;
|
||||||
GrouperName = string.Empty;
|
GroupName = string.Empty;
|
||||||
}
|
}
|
||||||
public PackRuleData(string assetPath, string collectPath, string grouperName)
|
public PackRuleData(string assetPath, string collectPath, string groupName)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = collectPath;
|
CollectPath = collectPath;
|
||||||
GrouperName = grouperName;
|
GroupName = groupName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using System.IO;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class AssetBundleInspector
|
||||||
|
{
|
||||||
|
[CustomEditor(typeof(AssetBundle))]
|
||||||
|
internal class AssetBundleEditor : UnityEditor.Editor
|
||||||
|
{
|
||||||
|
internal bool pathFoldout = false;
|
||||||
|
internal bool advancedFoldout = false;
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
AssetBundle bundle = target as AssetBundle;
|
||||||
|
|
||||||
|
using (new EditorGUI.DisabledScope(true))
|
||||||
|
{
|
||||||
|
var leftStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
|
||||||
|
leftStyle.alignment = TextAnchor.UpperLeft;
|
||||||
|
GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
|
||||||
|
|
||||||
|
var assetNames = bundle.GetAllAssetNames();
|
||||||
|
pathFoldout = EditorGUILayout.Foldout(pathFoldout, "Source Asset Paths");
|
||||||
|
if (pathFoldout)
|
||||||
|
{
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
foreach (var asset in assetNames)
|
||||||
|
EditorGUILayout.LabelField(asset);
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
}
|
||||||
|
|
||||||
|
advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced Data");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (advancedFoldout)
|
||||||
|
{
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
base.OnInspectorGUI();
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b8016a4c13444bf45830d714ab2aa430
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public static class AssetBundleRecorder
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<string, AssetBundle> _loadedAssetBundles = new Dictionary<string, AssetBundle>(1000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取AssetBundle对象,如果没有被缓存就重新加载。
|
||||||
|
/// </summary>
|
||||||
|
public static AssetBundle GetAssetBundle(string filePath)
|
||||||
|
{
|
||||||
|
// 如果文件不存在
|
||||||
|
if (File.Exists(filePath) == false)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Not found asset bundle file : {filePath}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证文件有效性(可能文件被加密)
|
||||||
|
byte[] fileData = File.ReadAllBytes(filePath);
|
||||||
|
if (EditorTools.CheckBundleFileValid(fileData) == false)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"The asset bundle file is invalid and may be encrypted : {filePath}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_loadedAssetBundles.TryGetValue(filePath, out AssetBundle bundle))
|
||||||
|
{
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
|
||||||
|
if(newBundle != null)
|
||||||
|
{
|
||||||
|
string[] assetNames = newBundle.GetAllAssetNames();
|
||||||
|
foreach (string name in assetNames)
|
||||||
|
{
|
||||||
|
newBundle.LoadAsset(name);
|
||||||
|
}
|
||||||
|
_loadedAssetBundles.Add(filePath, newBundle);
|
||||||
|
}
|
||||||
|
return newBundle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 卸载所有已经加载的AssetBundle文件
|
||||||
|
/// </summary>
|
||||||
|
public static void UnloadAll()
|
||||||
|
{
|
||||||
|
foreach(var valuePair in _loadedAssetBundles)
|
||||||
|
{
|
||||||
|
if (valuePair.Value != null)
|
||||||
|
valuePair.Value.Unload(true);
|
||||||
|
}
|
||||||
|
_loadedAssetBundles.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9b2b5e436ee882d41bf53082bf7b23a0
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -42,8 +42,9 @@ namespace YooAsset.Editor
|
|||||||
private BundleListReporterViewer _bundleListViewer;
|
private BundleListReporterViewer _bundleListViewer;
|
||||||
|
|
||||||
private EViewMode _viewMode;
|
private EViewMode _viewMode;
|
||||||
private string _searchKeyWord;
|
|
||||||
private BuildReport _buildReport;
|
private BuildReport _buildReport;
|
||||||
|
private string _reportFilePath;
|
||||||
|
private string _searchKeyWord;
|
||||||
|
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
@@ -92,6 +93,10 @@ namespace YooAsset.Editor
|
|||||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||||
_summaryViewer.AttachParent(root);
|
_summaryViewer.AttachParent(root);
|
||||||
}
|
}
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
AssetBundleRecorder.UnloadAll();
|
||||||
|
}
|
||||||
|
|
||||||
private void ImportBtn_onClick()
|
private void ImportBtn_onClick()
|
||||||
{
|
{
|
||||||
@@ -99,19 +104,20 @@ namespace YooAsset.Editor
|
|||||||
if (string.IsNullOrEmpty(selectFilePath))
|
if (string.IsNullOrEmpty(selectFilePath))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string jsonData = FileUtility.ReadFile(selectFilePath);
|
_reportFilePath = selectFilePath;
|
||||||
|
string jsonData = FileUtility.ReadFile(_reportFilePath);
|
||||||
_buildReport = BuildReport.Deserialize(jsonData);
|
_buildReport = BuildReport.Deserialize(jsonData);
|
||||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||||
_bundleListViewer.FillViewData(_buildReport, _searchKeyWord);
|
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||||
_summaryViewer.FillViewData(_buildReport);
|
_summaryViewer.FillViewData(_buildReport);
|
||||||
}
|
}
|
||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
{
|
{
|
||||||
_searchKeyWord = e.newValue;
|
_searchKeyWord = e.newValue;
|
||||||
if(_buildReport != null)
|
if (_buildReport != null)
|
||||||
{
|
{
|
||||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||||
_bundleListViewer.FillViewData(_buildReport, _searchKeyWord);
|
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ViewModeMenuAction0(DropdownMenuAction action)
|
private void ViewModeMenuAction0(DropdownMenuAction action)
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// Size
|
// Size
|
||||||
var label2 = element.Q<Label>("Label2");
|
var label2 = element.Q<Label>("Label2");
|
||||||
label2.text = (bundleInfo.SizeBytes / 1024f).ToString("f1") + " KB";
|
label2.text = EditorUtility.FormatBytes(bundleInfo.SizeBytes);
|
||||||
|
|
||||||
// Hash
|
// Hash
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ namespace YooAsset.Editor
|
|||||||
private ListView _includeListView;
|
private ListView _includeListView;
|
||||||
|
|
||||||
private BuildReport _buildReport;
|
private BuildReport _buildReport;
|
||||||
|
private string _reportFilePath;
|
||||||
private string _searchKeyWord;
|
private string _searchKeyWord;
|
||||||
private ESortMode _sortMode = ESortMode.BundleName;
|
private ESortMode _sortMode = ESortMode.BundleName;
|
||||||
private bool _descendingSort = false;
|
private bool _descendingSort = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化页面
|
/// 初始化页面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -93,9 +93,10 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 填充页面数据
|
/// 填充页面数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(BuildReport buildReport, string searchKeyWord)
|
public void FillViewData( BuildReport buildReport, string reprotFilePath, string searchKeyWord)
|
||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
|
_reportFilePath = reprotFilePath;
|
||||||
_searchKeyWord = searchKeyWord;
|
_searchKeyWord = searchKeyWord;
|
||||||
RefreshView();
|
RefreshView();
|
||||||
}
|
}
|
||||||
@@ -139,7 +140,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
else if (_sortMode == ESortMode.BundleTags)
|
else if (_sortMode == ESortMode.BundleTags)
|
||||||
{
|
{
|
||||||
if(_descendingSort)
|
if (_descendingSort)
|
||||||
return result.OrderByDescending(a => a.GetTagsString()).ToList();
|
return result.OrderByDescending(a => a.GetTagsString()).ToList();
|
||||||
else
|
else
|
||||||
return result.OrderBy(a => a.GetTagsString()).ToList();
|
return result.OrderBy(a => a.GetTagsString()).ToList();
|
||||||
@@ -171,7 +172,7 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
_topBar2.text = "Size ↑";
|
_topBar2.text = "Size ↑";
|
||||||
}
|
}
|
||||||
else if(_sortMode == ESortMode.BundleTags)
|
else if (_sortMode == ESortMode.BundleTags)
|
||||||
{
|
{
|
||||||
if (_descendingSort)
|
if (_descendingSort)
|
||||||
_topBar4.text = "Tags ↓";
|
_topBar4.text = "Tags ↓";
|
||||||
@@ -260,7 +261,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// Size
|
// Size
|
||||||
var label2 = element.Q<Label>("Label2");
|
var label2 = element.Q<Label>("Label2");
|
||||||
label2.text = (bundleInfo.SizeBytes / 1024f).ToString("f1") + " KB";
|
label2.text = EditorUtility.FormatBytes(bundleInfo.SizeBytes);
|
||||||
|
|
||||||
// Hash
|
// Hash
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
@@ -276,8 +277,22 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
ReportBundleInfo bundleInfo = item as ReportBundleInfo;
|
ReportBundleInfo bundleInfo = item as ReportBundleInfo;
|
||||||
FillIncludeListView(bundleInfo);
|
FillIncludeListView(bundleInfo);
|
||||||
|
ShowAssetBundleInspector(bundleInfo);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void ShowAssetBundleInspector(ReportBundleInfo bundleInfo)
|
||||||
|
{
|
||||||
|
if (bundleInfo.IsRawFile())
|
||||||
|
return;
|
||||||
|
|
||||||
|
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||||
|
string filePath = $"{rootDirectory}/{bundleInfo.Hash}";
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||||
|
else
|
||||||
|
Selection.activeObject = null;
|
||||||
|
}
|
||||||
private void TopBar1_clicked()
|
private void TopBar1_clicked()
|
||||||
{
|
{
|
||||||
if (_sortMode != ESortMode.BundleName)
|
if (_sortMode != ESortMode.BundleName)
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class EditorDefine
|
public class EditorDefine
|
||||||
{
|
{
|
||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 停靠窗口类型集合
|
/// 停靠窗口类型集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleGrouperWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow)};
|
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleCollectorWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow)};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System.Collections;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
@@ -15,7 +15,57 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class EditorTools
|
public static class EditorTools
|
||||||
{
|
{
|
||||||
|
static EditorTools()
|
||||||
|
{
|
||||||
|
InitAssembly();
|
||||||
|
}
|
||||||
|
|
||||||
#region Assembly
|
#region Assembly
|
||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
private static void InitAssembly()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取带继承关系的所有类的类型
|
||||||
|
/// </summary>
|
||||||
|
public static List<Type> GetAssignableTypes(System.Type parentType)
|
||||||
|
{
|
||||||
|
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom(parentType);
|
||||||
|
return collection.ToList();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
private static readonly List<Type> _cacheTypes = new List<Type>(10000);
|
||||||
|
private static void InitAssembly()
|
||||||
|
{
|
||||||
|
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
|
foreach (Assembly assembly in assemblies)
|
||||||
|
{
|
||||||
|
List<Type> types = assembly.GetTypes().ToList();
|
||||||
|
_cacheTypes.AddRange(types);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取带继承关系的所有类的类型
|
||||||
|
/// </summary>
|
||||||
|
public static List<Type> GetAssignableTypes(System.Type parentType)
|
||||||
|
{
|
||||||
|
List<Type> result = new List<Type>();
|
||||||
|
for (int i = 0; i < _cacheTypes.Count; i++)
|
||||||
|
{
|
||||||
|
Type type = _cacheTypes[i];
|
||||||
|
if (parentType.IsAssignableFrom(type))
|
||||||
|
{
|
||||||
|
if (type.Name == parentType.Name)
|
||||||
|
continue;
|
||||||
|
result.Add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 调用私有的静态方法
|
/// 调用私有的静态方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -190,7 +240,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 控制台
|
#region EditorConsole
|
||||||
private static MethodInfo _clearConsoleMethod;
|
private static MethodInfo _clearConsoleMethod;
|
||||||
private static MethodInfo ClearConsoleMethod
|
private static MethodInfo ClearConsoleMethod
|
||||||
{
|
{
|
||||||
@@ -551,40 +601,6 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 字符串
|
|
||||||
/// <summary>
|
|
||||||
/// 是否含有中文
|
|
||||||
/// </summary>
|
|
||||||
public static bool IncludeChinese(string content)
|
|
||||||
{
|
|
||||||
foreach (var c in content)
|
|
||||||
{
|
|
||||||
if (c >= 0x4e00 && c <= 0x9fbb)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否是数字
|
|
||||||
/// </summary>
|
|
||||||
public static bool IsNumber(string content)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(content))
|
|
||||||
return false;
|
|
||||||
string pattern = @"^\d*$";
|
|
||||||
return Regex.IsMatch(content, pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 首字母大写
|
|
||||||
/// </summary>
|
|
||||||
public static string Capitalize(string content)
|
|
||||||
{
|
|
||||||
return content.Substring(0, 1).ToUpper() + (content.Length > 1 ? content.Substring(1).ToLower() : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 截取字符串
|
/// 截取字符串
|
||||||
@@ -594,7 +610,7 @@ namespace YooAsset.Editor
|
|||||||
/// <param name="key">关键字</param>
|
/// <param name="key">关键字</param>
|
||||||
/// <param name="includeKey">分割的结果里是否包含关键字</param>
|
/// <param name="includeKey">分割的结果里是否包含关键字</param>
|
||||||
/// <param name="searchBegin">是否使用初始匹配的位置,否则使用末尾匹配的位置</param>
|
/// <param name="searchBegin">是否使用初始匹配的位置,否则使用末尾匹配的位置</param>
|
||||||
public static string Substring(string content, string key, bool includeKey, bool firstMatch = true)
|
private static string Substring(string content, string key, bool includeKey, bool firstMatch = true)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(key))
|
if (string.IsNullOrEmpty(key))
|
||||||
return content;
|
return content;
|
||||||
@@ -614,6 +630,7 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
return content.Substring(startIndex + key.Length);
|
return content.Substring(startIndex + key.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ namespace YooAsset.Editor
|
|||||||
List<string> allAssets = new List<string>(1000);
|
List<string> allAssets = new List<string>(1000);
|
||||||
|
|
||||||
// 获取所有打包的资源
|
// 获取所有打包的资源
|
||||||
List<CollectAssetInfo> allCollectInfos = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(EBuildMode.DryRunBuild);
|
||||||
List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList();
|
List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList();
|
||||||
foreach (var assetPath in collectAssets)
|
foreach (var assetPath in collectAssets)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载场景
|
/// 加载场景
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SceneOperationHandle LoadSceneAsync(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
|
public static SceneOperationHandle LoadSceneAsync(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
|
||||||
{
|
{
|
||||||
@@ -161,7 +161,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载资源对象
|
/// 加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static AssetOperationHandle LoadAssetAsync(string assetPath, System.Type assetType)
|
public static AssetOperationHandle LoadAssetAsync(string assetPath, System.Type assetType)
|
||||||
{
|
{
|
||||||
@@ -179,7 +179,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载所有子资源对象
|
/// 加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(string assetPath, System.Type assetType)
|
public static SubAssetsOperationHandle LoadSubAssetsAsync(string assetPath, System.Type assetType)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DependAssetBundleGrouper
|
internal class DependAssetBundleGroup
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源包加载器列表
|
/// 依赖的资源包加载器列表
|
||||||
@@ -12,7 +12,7 @@ namespace YooAsset
|
|||||||
private readonly List<AssetBundleLoaderBase> _dependBundles;
|
private readonly List<AssetBundleLoaderBase> _dependBundles;
|
||||||
|
|
||||||
|
|
||||||
public DependAssetBundleGrouper(string assetPath)
|
public DependAssetBundleGroup(string assetPath)
|
||||||
{
|
{
|
||||||
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ namespace YooAsset
|
|||||||
// 3. 检测APK拷贝文件结果
|
// 3. 检测APK拷贝文件结果
|
||||||
if (_steps == ESteps.CheckDownloadFromApk)
|
if (_steps == ESteps.CheckDownloadFromApk)
|
||||||
{
|
{
|
||||||
|
Progress = _fileRequester.Progress();
|
||||||
if (_fileRequester.IsDone() == false)
|
if (_fileRequester.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -336,6 +337,7 @@ namespace YooAsset
|
|||||||
// 3. 检测服务器下载结果
|
// 3. 检测服务器下载结果
|
||||||
if (_steps == ESteps.CheckDownloadFromWeb)
|
if (_steps == ESteps.CheckDownloadFromWeb)
|
||||||
{
|
{
|
||||||
|
Progress = _downloader.DownloadProgress;
|
||||||
if (_downloader.IsDone() == false)
|
if (_downloader.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -363,6 +365,7 @@ namespace YooAsset
|
|||||||
// 5. 检测APK拷贝文件结果
|
// 5. 检测APK拷贝文件结果
|
||||||
if (_steps == ESteps.CheckDownloadFromApk)
|
if (_steps == ESteps.CheckDownloadFromApk)
|
||||||
{
|
{
|
||||||
|
Progress = _fileRequester.Progress();
|
||||||
if (_fileRequester.IsDone() == false)
|
if (_fileRequester.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -26,19 +26,6 @@ namespace YooAsset
|
|||||||
private Scene _scene;
|
private Scene _scene;
|
||||||
private AsyncOperation _asyncOp;
|
private AsyncOperation _asyncOp;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 场景卸载进度
|
|
||||||
/// </summary>
|
|
||||||
public float Progress
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_asyncOp == null)
|
|
||||||
return 0;
|
|
||||||
return _asyncOp.progress;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal UnloadSceneOperation(string error)
|
internal UnloadSceneOperation(string error)
|
||||||
{
|
{
|
||||||
_flag = EFlag.Error;
|
_flag = EFlag.Error;
|
||||||
@@ -87,6 +74,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.Checking)
|
if (_steps == ESteps.Checking)
|
||||||
{
|
{
|
||||||
|
Progress = _asyncOp.progress;
|
||||||
if (_asyncOp.isDone == false)
|
if (_asyncOp.isDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ namespace YooAsset
|
|||||||
internal abstract class BundledProvider : ProviderBase
|
internal abstract class BundledProvider : ProviderBase
|
||||||
{
|
{
|
||||||
protected AssetBundleLoaderBase OwnerBundle { private set; get; }
|
protected AssetBundleLoaderBase OwnerBundle { private set; get; }
|
||||||
protected DependAssetBundleGrouper DependBundles { private set; get; }
|
protected DependAssetBundleGroup DependBundles { private set; get; }
|
||||||
|
|
||||||
public BundledProvider(string assetPath, System.Type assetType) : base(assetPath, assetType)
|
public BundledProvider(string assetPath, System.Type assetType) : base(assetPath, assetType)
|
||||||
{
|
{
|
||||||
OwnerBundle = AssetSystem.CreateOwnerAssetBundleLoader(assetPath);
|
OwnerBundle = AssetSystem.CreateOwnerAssetBundleLoader(assetPath);
|
||||||
OwnerBundle.Reference();
|
OwnerBundle.Reference();
|
||||||
OwnerBundle.AddProvider(this);
|
OwnerBundle.AddProvider(this);
|
||||||
DependBundles = new DependAssetBundleGrouper(assetPath);
|
DependBundles = new DependAssetBundleGroup(assetPath);
|
||||||
DependBundles.Reference();
|
DependBundles.Reference();
|
||||||
}
|
}
|
||||||
public override void Destroy()
|
public override void Destroy()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace YooAsset
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return 100f;
|
return 1f;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -39,10 +39,8 @@ namespace YooAsset
|
|||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
Status = EStatus.Loading;
|
||||||
Status = EStatus.Loading;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 注意:模拟异步加载效果提前返回
|
// 注意:模拟异步加载效果提前返回
|
||||||
if (IsWaitForAsyncComplete == false)
|
if (IsWaitForAsyncComplete == false)
|
||||||
@@ -52,7 +50,10 @@ namespace YooAsset
|
|||||||
// 1. 加载资源对象
|
// 1. 加载资源对象
|
||||||
if (Status == EStatus.Loading)
|
if (Status == EStatus.Loading)
|
||||||
{
|
{
|
||||||
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(AssetPath, AssetType);
|
if (AssetType == null)
|
||||||
|
AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(AssetPath);
|
||||||
|
else
|
||||||
|
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(AssetPath, AssetType);
|
||||||
Status = EStatus.Checking;
|
Status = EStatus.Checking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace YooAsset
|
|||||||
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
||||||
if (Status == EStatus.Fail)
|
if (Status == EStatus.Fail)
|
||||||
{
|
{
|
||||||
LastError = $"The load scene is invalid : {AssetPath}";
|
LastError = $"The loaded scene is invalid : {AssetPath}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(LastError);
|
||||||
}
|
}
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace YooAsset
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return 100f;
|
return 1f;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -39,10 +39,8 @@ namespace YooAsset
|
|||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
Status = EStatus.Loading;
|
||||||
Status = EStatus.Loading;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 注意:模拟异步加载效果提前返回
|
// 注意:模拟异步加载效果提前返回
|
||||||
if (IsWaitForAsyncComplete == false)
|
if (IsWaitForAsyncComplete == false)
|
||||||
@@ -62,7 +60,7 @@ namespace YooAsset
|
|||||||
List<UnityEngine.Object> result = new List<Object>(findAssets.Length);
|
List<UnityEngine.Object> result = new List<Object>(findAssets.Length);
|
||||||
foreach (var findAsset in findAssets)
|
foreach (var findAsset in findAssets)
|
||||||
{
|
{
|
||||||
if (findAsset.GetType() == AssetType)
|
if (AssetType.IsAssignableFrom(findAsset.GetType()))
|
||||||
result.Add(findAsset);
|
result.Add(findAsset);
|
||||||
}
|
}
|
||||||
AllAssetObjects = result.ToArray();
|
AllAssetObjects = result.ToArray();
|
||||||
|
|||||||
@@ -162,28 +162,6 @@ namespace YooAsset
|
|||||||
RefCount--;
|
RefCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否为场景提供者
|
|
||||||
/// </summary>
|
|
||||||
public bool IsSceneProvider()
|
|
||||||
{
|
|
||||||
if (this is BundledSceneProvider || this is DatabaseSceneProvider)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否为子资源对象提供者
|
|
||||||
/// </summary>
|
|
||||||
public bool IsSubAssetsProvider()
|
|
||||||
{
|
|
||||||
if (this is BundledSubAssetsProvider || this is DatabaseSubAssetsProvider)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 等待异步执行完毕
|
/// 等待异步执行完毕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -218,6 +196,21 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsSceneProvider()
|
||||||
|
{
|
||||||
|
if (this is BundledSceneProvider || this is DatabaseSceneProvider)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public bool IsSubAssetsProvider()
|
||||||
|
{
|
||||||
|
if (this is BundledSubAssetsProvider || this is DatabaseSubAssetsProvider)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#region 异步编程相关
|
#region 异步编程相关
|
||||||
private TaskCompletionSource<object> _taskCompletionSource;
|
private TaskCompletionSource<object> _taskCompletionSource;
|
||||||
protected void InvokeCompletion()
|
protected void InvokeCompletion()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载进度(0-100f)
|
/// 下载进度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float DownloadProgress
|
public float DownloadProgress
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace YooAsset
|
|||||||
// 检测下载结果
|
// 检测下载结果
|
||||||
if (_steps == ESteps.CheckDownload)
|
if (_steps == ESteps.CheckDownload)
|
||||||
{
|
{
|
||||||
_downloadProgress = _webRequest.downloadProgress * 100f;
|
_downloadProgress = _webRequest.downloadProgress;
|
||||||
_downloadedBytes = _webRequest.downloadedBytes;
|
_downloadedBytes = _webRequest.downloadedBytes;
|
||||||
if (_operationHandle.isDone == false)
|
if (_operationHandle.isDone == false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.CheckDownload)
|
if (_steps == ESteps.CheckDownload)
|
||||||
{
|
{
|
||||||
_downloadProgress = _threadDownloader.DownloadProgress * 100f;
|
_downloadProgress = _threadDownloader.DownloadProgress;
|
||||||
_downloadedBytes = _threadDownloader.DownloadedBytes;
|
_downloadedBytes = _threadDownloader.DownloadedBytes;
|
||||||
if (_threadDownloader.IsDone == false)
|
if (_threadDownloader.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -83,6 +83,16 @@ namespace YooAsset
|
|||||||
return _operationHandle.isDone;
|
return _operationHandle.isDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载进度
|
||||||
|
/// </summary>
|
||||||
|
public float Progress()
|
||||||
|
{
|
||||||
|
if (_operationHandle == null)
|
||||||
|
return 0;
|
||||||
|
return _operationHandle.progress;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载是否发生错误
|
/// 下载是否发生错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -60,6 +60,16 @@ namespace YooAsset
|
|||||||
return _operationHandle.isDone;
|
return _operationHandle.isDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载进度
|
||||||
|
/// </summary>
|
||||||
|
public float Progress()
|
||||||
|
{
|
||||||
|
if (_operationHandle == null)
|
||||||
|
return 0;
|
||||||
|
return _operationHandle.progress;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载是否发生错误
|
/// 下载是否发生错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -18,7 +18,12 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 错误信息
|
/// 错误信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Error { get; protected set; } = string.Empty;
|
public string Error { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理进度
|
||||||
|
/// </summary>
|
||||||
|
public float Progress { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否已经完成
|
/// 是否已经完成
|
||||||
@@ -70,8 +75,8 @@ namespace YooAsset
|
|||||||
internal abstract void Update();
|
internal abstract void Update();
|
||||||
internal void Finish()
|
internal void Finish()
|
||||||
{
|
{
|
||||||
|
Progress = 1f;
|
||||||
_callback?.Invoke(this);
|
_callback?.Invoke(this);
|
||||||
|
|
||||||
if (_taskCompletionSource != null)
|
if (_taskCompletionSource != null)
|
||||||
_taskCompletionSource.TrySetResult(null);
|
_taskCompletionSource.TrySetResult(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public class GameAsyncOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
OnStart();
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
OnUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnStart() { }
|
||||||
|
protected virtual void OnUpdate() { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ff8a96dd005f55346986f8a98aff8c99
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -9,7 +9,7 @@ namespace YooAsset
|
|||||||
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(100);
|
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(100);
|
||||||
|
|
||||||
// 计时器相关
|
// 计时器相关
|
||||||
private static Stopwatch _watch;
|
private static Stopwatch _watch;
|
||||||
private static long _maxTimeSlice;
|
private static long _maxTimeSlice;
|
||||||
private static long _frameTime;
|
private static long _frameTime;
|
||||||
|
|
||||||
@@ -35,11 +35,12 @@ namespace YooAsset
|
|||||||
if (_watch.ElapsedMilliseconds - _frameTime >= _maxTimeSlice)
|
if (_watch.ElapsedMilliseconds - _frameTime >= _maxTimeSlice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_operations[i].Update();
|
var operation = _operations[i];
|
||||||
if (_operations[i].IsDone)
|
operation.Update();
|
||||||
|
if (operation.IsDone)
|
||||||
{
|
{
|
||||||
_operations[i].Finish();
|
|
||||||
_operations.RemoveAt(i);
|
_operations.RemoveAt(i);
|
||||||
|
operation.Finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器资源路径
|
/// 编辑器资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string EditorAssetPath { private set; get; }
|
internal string EditorAssetPath { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_lastDownloadBytes = downloadBytes;
|
_lastDownloadBytes = downloadBytes;
|
||||||
_lastDownloadCount = CurrentDownloadCount;
|
_lastDownloadCount = CurrentDownloadCount;
|
||||||
|
Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
|
||||||
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
|
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,51 +13,63 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行的初始化操作
|
/// 编辑器下模拟模式的初始化操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class EditorPlayModeInitializationOperation : InitializationOperation
|
internal sealed class EditorSimulateModeInitializationOperation : InitializationOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Builder,
|
Builder,
|
||||||
|
Load,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly EditorPlayModeImpl _impl;
|
private readonly EditorSimulateModeImpl _impl;
|
||||||
|
private string _simulatePatchManifestPath;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal EditorPlayModeInitializationOperation(EditorPlayModeImpl impl)
|
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulatePatchManifestPath)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
|
_simulatePatchManifestPath = simulatePatchManifestPath;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
_steps = ESteps.Builder;
|
if (string.IsNullOrEmpty(_simulatePatchManifestPath))
|
||||||
|
_steps = ESteps.Builder;
|
||||||
|
else
|
||||||
|
_steps = ESteps.Load;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.Builder)
|
if (_steps == ESteps.Builder)
|
||||||
{
|
{
|
||||||
string manifestFilePath = EditorPlayModeHelper.DryRunBuild();
|
_simulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild();
|
||||||
if (string.IsNullOrEmpty(manifestFilePath))
|
if (string.IsNullOrEmpty(_simulatePatchManifestPath))
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = "Dry run build failed, see the detail info on the console window.";
|
Error = "Simulate build failed, see the detail info on the console window.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (File.Exists(manifestFilePath) == false)
|
_steps = ESteps.Load;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.Load)
|
||||||
|
{
|
||||||
|
if (File.Exists(_simulatePatchManifestPath) == false)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Manifest file not found : {manifestFilePath}";
|
Error = $"Manifest file not found : {_simulatePatchManifestPath}";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Log($"Load manifest file in editor play mode : {manifestFilePath}");
|
YooLogger.Log($"Load manifest file : {_simulatePatchManifestPath}");
|
||||||
string jsonContent = FileUtility.ReadFile(manifestFilePath);
|
string jsonContent = FileUtility.ReadFile(_simulatePatchManifestPath);
|
||||||
_impl.AppPatchManifest = PatchManifest.Deserialize(jsonContent);
|
var simulatePatchManifest = PatchManifest.Deserialize(jsonContent);
|
||||||
|
_impl.SetSimulatePatchManifest(simulatePatchManifest);
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
@@ -65,7 +77,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式的初始化操作
|
/// 离线运行模式的初始化操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class OfflinePlayModeInitializationOperation : InitializationOperation
|
internal sealed class OfflinePlayModeInitializationOperation : InitializationOperation
|
||||||
{
|
{
|
||||||
@@ -96,6 +108,7 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.Update)
|
if (_steps == ESteps.Update)
|
||||||
{
|
{
|
||||||
_appManifestLoader.Update();
|
_appManifestLoader.Update();
|
||||||
|
Progress = _appManifestLoader.Progress();
|
||||||
if (_appManifestLoader.IsDone() == false)
|
if (_appManifestLoader.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -104,20 +117,19 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _appManifestLoader.Error;
|
Error = _appManifestLoader.Error;
|
||||||
throw new System.Exception($"FATAL : {_appManifestLoader.Error}");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
_impl.AppPatchManifest = _appManifestLoader.Result;
|
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网络模式的初始化操作
|
/// 网络运行模式的初始化操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
||||||
{
|
{
|
||||||
@@ -170,6 +182,7 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.Update)
|
if (_steps == ESteps.Update)
|
||||||
{
|
{
|
||||||
_appManifestLoader.Update();
|
_appManifestLoader.Update();
|
||||||
|
Progress = _appManifestLoader.Progress();
|
||||||
if (_appManifestLoader.IsDone() == false)
|
if (_appManifestLoader.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -178,14 +191,13 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _appManifestLoader.Error;
|
Error = _appManifestLoader.Error;
|
||||||
throw new System.Exception($"FATAL : {_appManifestLoader.Error}");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
_impl.AppPatchManifest = _appManifestLoader.Result;
|
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
||||||
_impl.LocalPatchManifest = _appManifestLoader.Result;
|
_impl.SetLocalPatchManifest(_appManifestLoader.Result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,6 +245,16 @@ namespace YooAsset
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载进度
|
||||||
|
/// </summary>
|
||||||
|
public float Progress()
|
||||||
|
{
|
||||||
|
if (_downloader2 == null)
|
||||||
|
return 0;
|
||||||
|
return _downloader2.Progress();
|
||||||
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (IsDone())
|
if (IsDone())
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.UpdateVerifyingCache)
|
if (_steps == ESteps.UpdateVerifyingCache)
|
||||||
{
|
{
|
||||||
|
Progress = GetVerifyProgress();
|
||||||
if (UpdateVerifyingCache())
|
if (UpdateVerifyingCache())
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
@@ -201,7 +202,8 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_impl.LocalPatchManifest = PatchManifest.Deserialize(content);
|
var remotePatchManifest = PatchManifest.Deserialize(content);
|
||||||
|
_impl.SetLocalPatchManifest(remotePatchManifest);
|
||||||
|
|
||||||
YooLogger.Log("Save remote patch manifest file.");
|
YooLogger.Log("Save remote patch manifest file.");
|
||||||
string savePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
string savePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
||||||
@@ -223,7 +225,8 @@ namespace YooAsset
|
|||||||
YooLogger.Log("Load sandbox patch manifest file.");
|
YooLogger.Log("Load sandbox patch manifest file.");
|
||||||
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
||||||
string jsonData = File.ReadAllText(filePath);
|
string jsonData = File.ReadAllText(filePath);
|
||||||
_impl.LocalPatchManifest = PatchManifest.Deserialize(jsonData);
|
var sandboxPatchManifest = PatchManifest.Deserialize(jsonData);
|
||||||
|
_impl.SetLocalPatchManifest(sandboxPatchManifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -256,6 +259,7 @@ namespace YooAsset
|
|||||||
private readonly List<PatchBundle> _verifyingList = new List<PatchBundle>(100);
|
private readonly List<PatchBundle> _verifyingList = new List<PatchBundle>(100);
|
||||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||||
private int _verifyMaxNum = 32;
|
private int _verifyMaxNum = 32;
|
||||||
|
private int _verifyTotalCount = 0;
|
||||||
private int _verifySuccessCount = 0;
|
private int _verifySuccessCount = 0;
|
||||||
private int _verifyFailCount = 0;
|
private int _verifyFailCount = 0;
|
||||||
|
|
||||||
@@ -288,6 +292,7 @@ namespace YooAsset
|
|||||||
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
|
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
|
||||||
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
||||||
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
||||||
|
_verifyTotalCount = _waitingList.Count;
|
||||||
}
|
}
|
||||||
private bool UpdateVerifyingCache()
|
private bool UpdateVerifyingCache()
|
||||||
{
|
{
|
||||||
@@ -356,6 +361,12 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
_verifyingList.Remove(info.Bundle);
|
_verifyingList.Remove(info.Bundle);
|
||||||
}
|
}
|
||||||
|
private float GetVerifyProgress()
|
||||||
|
{
|
||||||
|
if (_verifyTotalCount == 0)
|
||||||
|
return 1f;
|
||||||
|
return (float)(_verifySuccessCount + _verifyFailCount) / _verifyTotalCount;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,6 +111,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.CheckWebManifest)
|
if (_steps == ESteps.CheckWebManifest)
|
||||||
{
|
{
|
||||||
|
Progress = _downloaderManifest.Progress();
|
||||||
if (_downloaderManifest.IsDone() == false)
|
if (_downloaderManifest.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.CheckStaticVersion)
|
if (_steps == ESteps.CheckStaticVersion)
|
||||||
{
|
{
|
||||||
|
Progress = _downloader.Progress();
|
||||||
if (_downloader.IsDone() == false)
|
if (_downloader.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ namespace YooAsset
|
|||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"URL : {_downloader.URL} Error : static version content is invalid.";
|
Error = $"URL : {_downloader.URL} Error : static version content is invalid.";
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ namespace YooAsset
|
|||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public readonly Dictionary<string, string> AssetPathMapping = new Dictionary<string, string>();
|
public readonly Dictionary<string, string> AssetPathMapping = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
// 资源路径映射相关
|
||||||
|
private bool _isInitAssetPathMapping = false;
|
||||||
|
private bool _locationToLower = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置资源标签列表
|
/// 获取内置资源标签列表
|
||||||
@@ -141,18 +145,72 @@ namespace YooAsset
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化资源路径映射
|
||||||
|
/// </summary>
|
||||||
|
public void InitAssetPathMapping(bool locationToLower)
|
||||||
|
{
|
||||||
|
if (_isInitAssetPathMapping)
|
||||||
|
return;
|
||||||
|
_isInitAssetPathMapping = true;
|
||||||
|
|
||||||
|
if (EnableAddressable)
|
||||||
|
{
|
||||||
|
if (locationToLower)
|
||||||
|
YooLogger.Warning("Addressable not support location to lower !");
|
||||||
|
|
||||||
|
foreach (var patchAsset in AssetList)
|
||||||
|
{
|
||||||
|
string location = patchAsset.Address;
|
||||||
|
if (AssetPathMapping.ContainsKey(location))
|
||||||
|
throw new Exception($"Address have existed : {location}");
|
||||||
|
else
|
||||||
|
AssetPathMapping.Add(location, patchAsset.AssetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_locationToLower = locationToLower;
|
||||||
|
foreach (var patchAsset in AssetList)
|
||||||
|
{
|
||||||
|
string location = patchAsset.AssetPath;
|
||||||
|
if (locationToLower)
|
||||||
|
location = location.ToLower();
|
||||||
|
|
||||||
|
// 添加原生路径的映射
|
||||||
|
if (AssetPathMapping.ContainsKey(location))
|
||||||
|
throw new Exception($"AssetPath have existed : {location}");
|
||||||
|
else
|
||||||
|
AssetPathMapping.Add(location, patchAsset.AssetPath);
|
||||||
|
|
||||||
|
// 添加无后缀名路径的映射
|
||||||
|
if (Path.HasExtension(location))
|
||||||
|
{
|
||||||
|
string locationWithoutExtension = StringUtility.RemoveExtension(location);
|
||||||
|
if (AssetPathMapping.ContainsKey(locationWithoutExtension))
|
||||||
|
YooLogger.Warning($"AssetPath have existed : {locationWithoutExtension}");
|
||||||
|
else
|
||||||
|
AssetPathMapping.Add(locationWithoutExtension, patchAsset.AssetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 映射为资源路径
|
/// 映射为资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string MappingToAssetPath(string location)
|
public string MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
|
if (_locationToLower)
|
||||||
|
location = location.ToLower();
|
||||||
|
|
||||||
if (AssetPathMapping.TryGetValue(location, out string assetPath))
|
if (AssetPathMapping.TryGetValue(location, out string assetPath))
|
||||||
{
|
{
|
||||||
return assetPath;
|
return assetPath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Failed to mapping location to asset path : {location}");
|
YooLogger.Error($"Failed to mapping location to asset path : {location}");
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,42 +250,6 @@ namespace YooAsset
|
|||||||
patchManifest.Assets.Add(assetPath, patchAsset);
|
patchManifest.Assets.Add(assetPath, patchAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AssetPathMapping
|
|
||||||
if (patchManifest.EnableAddressable)
|
|
||||||
{
|
|
||||||
foreach (var patchAsset in patchManifest.AssetList)
|
|
||||||
{
|
|
||||||
string address = patchAsset.Address;
|
|
||||||
if (patchManifest.AssetPathMapping.ContainsKey(address))
|
|
||||||
throw new Exception($"Address have existed : {address}");
|
|
||||||
else
|
|
||||||
patchManifest.AssetPathMapping.Add(address, patchAsset.AssetPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var patchAsset in patchManifest.AssetList)
|
|
||||||
{
|
|
||||||
string assetPath = patchAsset.AssetPath;
|
|
||||||
|
|
||||||
// 添加原生路径的映射
|
|
||||||
if (patchManifest.AssetPathMapping.ContainsKey(assetPath))
|
|
||||||
throw new Exception($"AssetPath have existed : {assetPath}");
|
|
||||||
else
|
|
||||||
patchManifest.AssetPathMapping.Add(assetPath, assetPath);
|
|
||||||
|
|
||||||
// 添加无后缀名路径的映射
|
|
||||||
if (Path.HasExtension(assetPath))
|
|
||||||
{
|
|
||||||
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
|
|
||||||
if (patchManifest.AssetPathMapping.ContainsKey(assetPathWithoutExtension))
|
|
||||||
YooLogger.Warning($"AssetPath have existed : {assetPathWithoutExtension}");
|
|
||||||
else
|
|
||||||
patchManifest.AssetPathMapping.Add(assetPathWithoutExtension, assetPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return patchManifest;
|
return patchManifest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
internal class EditorPlayModeImpl : IBundleServices
|
|
||||||
{
|
|
||||||
internal PatchManifest AppPatchManifest;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步初始化
|
|
||||||
/// </summary>
|
|
||||||
public InitializationOperation InitializeAsync()
|
|
||||||
{
|
|
||||||
var operation = new EditorPlayModeInitializationOperation(this);
|
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取资源版本号
|
|
||||||
/// </summary>
|
|
||||||
public int GetResourceVersion()
|
|
||||||
{
|
|
||||||
if (AppPatchManifest == null)
|
|
||||||
return 0;
|
|
||||||
return AppPatchManifest.ResourceVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IBundleServices接口
|
|
||||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
|
||||||
return new BundleInfo(string.Empty);
|
|
||||||
|
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
|
||||||
{
|
|
||||||
string mainAssetPath = AppPatchManifest.TryGetBundleMainAssetPath(bundleName);
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, mainAssetPath);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
|
||||||
{
|
|
||||||
return PatchHelper.GetAssetsInfoByTag(AppPatchManifest, tags);
|
|
||||||
}
|
|
||||||
string IBundleServices.MappingToAssetPath(string location)
|
|
||||||
{
|
|
||||||
return AppPatchManifest.MappingToAssetPath(location);
|
|
||||||
}
|
|
||||||
string IBundleServices.GetBundleName(string assetPath)
|
|
||||||
{
|
|
||||||
return AppPatchManifest.GetBundleName(assetPath);
|
|
||||||
}
|
|
||||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
|
||||||
{
|
|
||||||
return AppPatchManifest.GetAllDependencies(assetPath);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,19 +3,19 @@ using System.Reflection;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal static class EditorPlayModeHelper
|
internal static class EditorSimulateModeHelper
|
||||||
{
|
{
|
||||||
private static System.Type _classType;
|
private static System.Type _classType;
|
||||||
|
|
||||||
public static string DryRunBuild()
|
public static string SimulateBuild()
|
||||||
{
|
{
|
||||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleRuntimeBuilder");
|
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleSimulateBuilder");
|
||||||
InvokePublicStaticMethod(_classType, "FastBuild");
|
InvokePublicStaticMethod(_classType, "SimulateBuild");
|
||||||
return GetPatchManifestFilePath();
|
return GetPatchManifestFilePath();
|
||||||
}
|
}
|
||||||
private static string GetPatchManifestFilePath()
|
private static string GetPatchManifestFilePath()
|
||||||
{
|
{
|
||||||
return (string)InvokePublicStaticMethod(_classType, "GetPatchManifestFilePath");
|
return (string)InvokePublicStaticMethod(_classType, "GetPatchManifestPath");
|
||||||
}
|
}
|
||||||
private static object InvokePublicStaticMethod(System.Type type, string method, params object[] parameters)
|
private static object InvokePublicStaticMethod(System.Type type, string method, params object[] parameters)
|
||||||
{
|
{
|
||||||
@@ -30,8 +30,8 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
internal static class EditorPlayModeHelper
|
internal static class EditorSimulateModeHelper
|
||||||
{
|
{
|
||||||
public static string DryRunBuild() { throw new System.Exception("Only support in unity editor !"); }
|
public static string SimulateBuild() { throw new System.Exception("Only support in unity editor !"); }
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class EditorSimulateModeImpl : IBundleServices
|
||||||
|
{
|
||||||
|
private PatchManifest _simulatePatchManifest;
|
||||||
|
private bool _locationToLower;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步初始化
|
||||||
|
/// </summary>
|
||||||
|
public InitializationOperation InitializeAsync(bool locationToLower, string simulatePatchManifestPath)
|
||||||
|
{
|
||||||
|
_locationToLower = locationToLower;
|
||||||
|
var operation = new EditorSimulateModeInitializationOperation(this, simulatePatchManifestPath);
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源版本号
|
||||||
|
/// </summary>
|
||||||
|
public int GetResourceVersion()
|
||||||
|
{
|
||||||
|
if (_simulatePatchManifest == null)
|
||||||
|
return 0;
|
||||||
|
return _simulatePatchManifest.ResourceVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置资源清单
|
||||||
|
internal void SetSimulatePatchManifest(PatchManifest patchManifest)
|
||||||
|
{
|
||||||
|
_simulatePatchManifest = patchManifest;
|
||||||
|
_simulatePatchManifest.InitAssetPathMapping(_locationToLower);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IBundleServices接口
|
||||||
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
|
return new BundleInfo(string.Empty);
|
||||||
|
|
||||||
|
if (_simulatePatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||||
|
{
|
||||||
|
string mainAssetPath = _simulatePatchManifest.TryGetBundleMainAssetPath(bundleName);
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, mainAssetPath);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AssetInfo[] IBundleServices.GetAssetInfos(string bundleName)
|
||||||
|
{
|
||||||
|
return PatchHelper.GetAssetsInfoByBundleName(_simulatePatchManifest, bundleName);
|
||||||
|
}
|
||||||
|
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||||
|
{
|
||||||
|
return PatchHelper.GetAssetsInfoByTags(_simulatePatchManifest, tags);
|
||||||
|
}
|
||||||
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
|
{
|
||||||
|
return _simulatePatchManifest.MappingToAssetPath(location);
|
||||||
|
}
|
||||||
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
|
{
|
||||||
|
return _simulatePatchManifest.GetBundleName(assetPath);
|
||||||
|
}
|
||||||
|
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||||
|
{
|
||||||
|
return _simulatePatchManifest.GetAllDependencies(assetPath);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,10 +8,11 @@ namespace YooAsset
|
|||||||
internal class HostPlayModeImpl : IBundleServices
|
internal class HostPlayModeImpl : IBundleServices
|
||||||
{
|
{
|
||||||
// 补丁清单
|
// 补丁清单
|
||||||
internal PatchManifest AppPatchManifest;
|
internal PatchManifest AppPatchManifest { private set; get; }
|
||||||
internal PatchManifest LocalPatchManifest;
|
internal PatchManifest LocalPatchManifest { private set; get; }
|
||||||
|
|
||||||
// 参数相关
|
// 参数相关
|
||||||
|
internal bool LocationToLower { private set; get; }
|
||||||
internal bool ClearCacheWhenDirty { private set; get; }
|
internal bool ClearCacheWhenDirty { private set; get; }
|
||||||
private string _defaultHostServer;
|
private string _defaultHostServer;
|
||||||
private string _fallbackHostServer;
|
private string _fallbackHostServer;
|
||||||
@@ -19,8 +20,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(bool clearCacheWhenDirty, string defaultHostServer, string fallbackHostServer)
|
public InitializationOperation InitializeAsync(bool locationToLower, bool clearCacheWhenDirty, string defaultHostServer, string fallbackHostServer)
|
||||||
{
|
{
|
||||||
|
LocationToLower = locationToLower;
|
||||||
ClearCacheWhenDirty = clearCacheWhenDirty;
|
ClearCacheWhenDirty = clearCacheWhenDirty;
|
||||||
_defaultHostServer = defaultHostServer;
|
_defaultHostServer = defaultHostServer;
|
||||||
_fallbackHostServer = fallbackHostServer;
|
_fallbackHostServer = fallbackHostServer;
|
||||||
@@ -274,6 +276,17 @@ namespace YooAsset
|
|||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置资源清单
|
||||||
|
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||||
|
{
|
||||||
|
AppPatchManifest = patchManifest;
|
||||||
|
}
|
||||||
|
internal void SetLocalPatchManifest(PatchManifest patchManifest)
|
||||||
|
{
|
||||||
|
LocalPatchManifest = patchManifest;
|
||||||
|
LocalPatchManifest.InitAssetPathMapping(LocationToLower);
|
||||||
|
}
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
@@ -309,9 +322,13 @@ namespace YooAsset
|
|||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AssetInfo[] IBundleServices.GetAssetInfos(string bundleName)
|
||||||
|
{
|
||||||
|
return PatchHelper.GetAssetsInfoByBundleName(LocalPatchManifest, bundleName);
|
||||||
|
}
|
||||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||||
{
|
{
|
||||||
return PatchHelper.GetAssetsInfoByTag(LocalPatchManifest, tags);
|
return PatchHelper.GetAssetsInfoByTags(LocalPatchManifest, tags);
|
||||||
}
|
}
|
||||||
string IBundleServices.MappingToAssetPath(string location)
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal class OfflinePlayModeImpl : IBundleServices
|
internal class OfflinePlayModeImpl : IBundleServices
|
||||||
{
|
{
|
||||||
internal PatchManifest AppPatchManifest;
|
private PatchManifest _appPatchManifest;
|
||||||
|
private bool _locationToLower;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync()
|
public InitializationOperation InitializeAsync(bool locationToLower)
|
||||||
{
|
{
|
||||||
|
_locationToLower = locationToLower;
|
||||||
var operation = new OfflinePlayModeInitializationOperation(this);
|
var operation = new OfflinePlayModeInitializationOperation(this);
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
@@ -23,9 +25,9 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int GetResourceVersion()
|
public int GetResourceVersion()
|
||||||
{
|
{
|
||||||
if (AppPatchManifest == null)
|
if (_appPatchManifest == null)
|
||||||
return 0;
|
return 0;
|
||||||
return AppPatchManifest.ResourceVersion;
|
return _appPatchManifest.ResourceVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -33,18 +35,25 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(AppPatchManifest, tags);
|
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(_appPatchManifest, tags);
|
||||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置资源清单
|
||||||
|
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||||
|
{
|
||||||
|
_appPatchManifest = patchManifest;
|
||||||
|
_appPatchManifest.InitAssetPathMapping(_locationToLower);
|
||||||
|
}
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
return new BundleInfo(string.Empty);
|
return new BundleInfo(string.Empty);
|
||||||
|
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
if (_appPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
@@ -56,21 +65,25 @@ namespace YooAsset
|
|||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AssetInfo[] IBundleServices.GetAssetInfos(string bundleName)
|
||||||
|
{
|
||||||
|
return PatchHelper.GetAssetsInfoByBundleName(_appPatchManifest, bundleName);
|
||||||
|
}
|
||||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||||
{
|
{
|
||||||
return PatchHelper.GetAssetsInfoByTag(AppPatchManifest, tags);
|
return PatchHelper.GetAssetsInfoByTags(_appPatchManifest, tags);
|
||||||
}
|
}
|
||||||
string IBundleServices.MappingToAssetPath(string location)
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return AppPatchManifest.MappingToAssetPath(location);
|
return _appPatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.GetBundleName(string assetPath)
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
{
|
{
|
||||||
return AppPatchManifest.GetBundleName(assetPath);
|
return _appPatchManifest.GetBundleName(assetPath);
|
||||||
}
|
}
|
||||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||||
{
|
{
|
||||||
return AppPatchManifest.GetAllDependencies(assetPath);
|
return _appPatchManifest.GetAllDependencies(assetPath);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
BundleInfo GetBundleInfo(string bundleName);
|
BundleInfo GetBundleInfo(string bundleName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源信息列表
|
||||||
|
/// </summary>
|
||||||
|
AssetInfo[] GetAssetInfos(string bundleName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源信息列表
|
/// 获取资源信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源信息列表
|
/// 获取资源信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static AssetInfo[] GetAssetsInfoByTag(PatchManifest patchManifest, string[] tags)
|
public static AssetInfo[] GetAssetsInfoByTags(PatchManifest patchManifest, string[] tags)
|
||||||
{
|
{
|
||||||
List<AssetInfo> result = new List<AssetInfo>(100);
|
List<AssetInfo> result = new List<AssetInfo>(100);
|
||||||
foreach (var patchAsset in patchManifest.AssetList)
|
foreach (var patchAsset in patchManifest.AssetList)
|
||||||
@@ -189,5 +189,20 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源信息列表
|
||||||
|
/// </summary>
|
||||||
|
public static AssetInfo[] GetAssetsInfoByBundleName(PatchManifest patchManifest, string bundleName)
|
||||||
|
{
|
||||||
|
List<AssetInfo> result = new List<AssetInfo>(100);
|
||||||
|
foreach (var patchAsset in patchManifest.AssetList)
|
||||||
|
{
|
||||||
|
string tempName = patchManifest.GetBundleName(patchAsset.AssetPath);
|
||||||
|
if (tempName == bundleName)
|
||||||
|
result.Add(new AssetInfo(patchAsset.AssetPath));
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
@@ -13,17 +14,18 @@ namespace YooAsset
|
|||||||
public enum EPlayMode
|
public enum EPlayMode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行模式
|
/// 编辑器下的模拟模式
|
||||||
|
/// 注意:在初始化的时候自动构建真机模拟环境。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
EditorPlayMode,
|
EditorSimulateMode,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式
|
/// 离线运行模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
OfflinePlayMode,
|
OfflinePlayMode,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网络模式
|
/// 网络运行模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
HostPlayMode,
|
HostPlayMode,
|
||||||
}
|
}
|
||||||
@@ -33,6 +35,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class CreateParameters
|
public abstract class CreateParameters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源定位地址大小写不敏感
|
||||||
|
/// </summary>
|
||||||
|
public bool LocationToLower = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位服务接口
|
/// 资源定位服务接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -55,21 +62,26 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行模式参数
|
/// 编辑器下模拟运行模式的初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorPlayModeParameters : CreateParameters
|
public class EditorSimulateModeParameters : CreateParameters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用于模拟运行的资源清单路径
|
||||||
|
/// 注意:如果路径为空,会自动重新构建补丁清单。
|
||||||
|
/// </summary>
|
||||||
|
public string SimulatePatchManifestPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式参数
|
/// 离线运行模式的初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OfflinePlayModeParameters : CreateParameters
|
public class OfflinePlayModeParameters : CreateParameters
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网络模式参数
|
/// 网络运行模式的初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HostPlayModeParameters : CreateParameters
|
public class HostPlayModeParameters : CreateParameters
|
||||||
{
|
{
|
||||||
@@ -96,10 +108,12 @@ namespace YooAsset
|
|||||||
|
|
||||||
|
|
||||||
private static bool _isInitialize = false;
|
private static bool _isInitialize = false;
|
||||||
|
private static string _initializeError = string.Empty;
|
||||||
|
private static EOperationStatus _initializeStatus = EOperationStatus.None;
|
||||||
private static EPlayMode _playMode;
|
private static EPlayMode _playMode;
|
||||||
private static IBundleServices _bundleServices;
|
private static IBundleServices _bundleServices;
|
||||||
private static ILocationServices _locationServices;
|
private static ILocationServices _locationServices;
|
||||||
private static EditorPlayModeImpl _editorPlayModeImpl;
|
private static EditorSimulateModeImpl _editorSimulateModeImpl;
|
||||||
private static OfflinePlayModeImpl _offlinePlayModeImpl;
|
private static OfflinePlayModeImpl _offlinePlayModeImpl;
|
||||||
private static HostPlayModeImpl _hostPlayModeImpl;
|
private static HostPlayModeImpl _hostPlayModeImpl;
|
||||||
|
|
||||||
@@ -118,8 +132,8 @@ namespace YooAsset
|
|||||||
_locationServices = parameters.LocationServices;
|
_locationServices = parameters.LocationServices;
|
||||||
|
|
||||||
#if !UNITY_EDITOR
|
#if !UNITY_EDITOR
|
||||||
if (parameters is EditorPlayModeParameters)
|
if (parameters is EditorSimulateModeParameters)
|
||||||
throw new Exception($"Editor play mode only support unity editor.");
|
throw new Exception($"Editor simulate mode only support unity editor.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 创建驱动器
|
// 创建驱动器
|
||||||
@@ -141,15 +155,15 @@ namespace YooAsset
|
|||||||
YooLogger.Warning($"{nameof(parameters.AssetLoadingMaxNumber)} minimum value is 1");
|
YooLogger.Warning($"{nameof(parameters.AssetLoadingMaxNumber)} minimum value is 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters.OperationSystemMaxTimeSlice < 33)
|
if (parameters.OperationSystemMaxTimeSlice < 30)
|
||||||
{
|
{
|
||||||
parameters.OperationSystemMaxTimeSlice = 33;
|
parameters.OperationSystemMaxTimeSlice = 30;
|
||||||
YooLogger.Warning($"{nameof(parameters.OperationSystemMaxTimeSlice)} minimum value is 33 milliseconds");
|
YooLogger.Warning($"{nameof(parameters.OperationSystemMaxTimeSlice)} minimum value is 33 milliseconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 运行模式
|
// 运行模式
|
||||||
if (parameters is EditorPlayModeParameters)
|
if (parameters is EditorSimulateModeParameters)
|
||||||
_playMode = EPlayMode.EditorPlayMode;
|
_playMode = EPlayMode.EditorSimulateMode;
|
||||||
else if (parameters is OfflinePlayModeParameters)
|
else if (parameters is OfflinePlayModeParameters)
|
||||||
_playMode = EPlayMode.OfflinePlayMode;
|
_playMode = EPlayMode.OfflinePlayMode;
|
||||||
else if (parameters is HostPlayModeParameters)
|
else if (parameters is HostPlayModeParameters)
|
||||||
@@ -172,19 +186,23 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化资源系统
|
// 初始化资源系统
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
InitializationOperation initializeOperation;
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
_editorPlayModeImpl = new EditorPlayModeImpl();
|
_editorSimulateModeImpl = new EditorSimulateModeImpl();
|
||||||
_bundleServices = _editorPlayModeImpl;
|
_bundleServices = _editorSimulateModeImpl;
|
||||||
AssetSystem.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
AssetSystem.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
return _editorPlayModeImpl.InitializeAsync();
|
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
||||||
|
initializeOperation = _editorSimulateModeImpl.InitializeAsync(
|
||||||
|
editorSimulateModeParameters.LocationToLower,
|
||||||
|
editorSimulateModeParameters.SimulatePatchManifestPath);
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
_offlinePlayModeImpl = new OfflinePlayModeImpl();
|
_offlinePlayModeImpl = new OfflinePlayModeImpl();
|
||||||
_bundleServices = _offlinePlayModeImpl;
|
_bundleServices = _offlinePlayModeImpl;
|
||||||
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
return _offlinePlayModeImpl.InitializeAsync();
|
initializeOperation = _offlinePlayModeImpl.InitializeAsync(parameters.LocationToLower);
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
@@ -192,7 +210,8 @@ namespace YooAsset
|
|||||||
_bundleServices = _hostPlayModeImpl;
|
_bundleServices = _hostPlayModeImpl;
|
||||||
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
||||||
return _hostPlayModeImpl.InitializeAsync(
|
initializeOperation = _hostPlayModeImpl.InitializeAsync(
|
||||||
|
hostPlayModeParameters.LocationToLower,
|
||||||
hostPlayModeParameters.ClearCacheWhenDirty,
|
hostPlayModeParameters.ClearCacheWhenDirty,
|
||||||
hostPlayModeParameters.DefaultHostServer,
|
hostPlayModeParameters.DefaultHostServer,
|
||||||
hostPlayModeParameters.FallbackHostServer);
|
hostPlayModeParameters.FallbackHostServer);
|
||||||
@@ -201,6 +220,15 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听初始化结果
|
||||||
|
initializeOperation.Completed += InitializeOperation_Completed;
|
||||||
|
return initializeOperation;
|
||||||
|
}
|
||||||
|
private static void InitializeOperation_Completed(AsyncOperationBase op)
|
||||||
|
{
|
||||||
|
_initializeStatus = op.Status;
|
||||||
|
_initializeError = op.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -209,7 +237,8 @@ namespace YooAsset
|
|||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeUpdateStaticVersionOperation();
|
var operation = new EditorPlayModeUpdateStaticVersionOperation();
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
@@ -240,7 +269,8 @@ namespace YooAsset
|
|||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public static UpdateManifestOperation UpdateManifestAsync(int resourceVersion, int timeout = 60)
|
public static UpdateManifestOperation UpdateManifestAsync(int resourceVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeUpdateManifestOperation();
|
var operation = new EditorPlayModeUpdateManifestOperation();
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
@@ -264,16 +294,26 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开启一个异步操作
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="operation">异步操作对象</param>
|
||||||
|
public static void ProcessOperaiton(GameAsyncOperation operation)
|
||||||
|
{
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源版本号
|
/// 获取资源版本号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int GetResourceVersion()
|
public static int GetResourceVersion()
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
if (_editorPlayModeImpl == null)
|
if (_editorSimulateModeImpl == null)
|
||||||
throw new Exception("YooAsset is not initialized.");
|
throw new Exception("YooAsset is not initialized.");
|
||||||
return _editorPlayModeImpl.GetResourceVersion();
|
return _editorSimulateModeImpl.GetResourceVersion();
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
@@ -310,12 +350,25 @@ namespace YooAsset
|
|||||||
AssetSystem.ForceUnloadAllAssets();
|
AssetSystem.ForceUnloadAllAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取调试信息
|
||||||
|
/// </summary>
|
||||||
|
internal static void GetDebugReport(DebugReport report)
|
||||||
|
{
|
||||||
|
if (report == null)
|
||||||
|
YooLogger.Error($"{nameof(DebugReport)} is null");
|
||||||
|
|
||||||
|
AssetSystem.GetDebugReport(report);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 资源信息
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包信息
|
/// 获取资源包信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static BundleInfo GetBundleInfo(string location)
|
public static BundleInfo GetBundleInfo(string location)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
string bundleName = _bundleServices.GetBundleName(assetPath);
|
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||||
return _bundleServices.GetBundleInfo(bundleName);
|
return _bundleServices.GetBundleInfo(bundleName);
|
||||||
@@ -327,31 +380,42 @@ namespace YooAsset
|
|||||||
/// <param name="assetInfo">资源信息</param>
|
/// <param name="assetInfo">资源信息</param>
|
||||||
public static BundleInfo GetBundleInfo(AssetInfo assetInfo)
|
public static BundleInfo GetBundleInfo(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
string bundleName = _bundleServices.GetBundleName(assetInfo.AssetPath);
|
string bundleName = _bundleServices.GetBundleName(assetInfo.AssetPath);
|
||||||
return _bundleServices.GetBundleInfo(bundleName);
|
return _bundleServices.GetBundleInfo(bundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源信息列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bundleInfo">资源包信息</param>
|
||||||
|
public static AssetInfo[] GetAssetInfos(BundleInfo bundleInfo)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
return _bundleServices.GetAssetInfos(bundleInfo.BundleName);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源信息列表
|
/// 获取资源信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tag">资源标签</param>
|
/// <param name="tag">资源标签</param>
|
||||||
/// <returns></returns>
|
|
||||||
public static AssetInfo[] GetAssetInfos(string tag)
|
public static AssetInfo[] GetAssetInfos(string tag)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
string[] tags = new string[] { tag };
|
string[] tags = new string[] { tag };
|
||||||
return _bundleServices.GetAssetInfos(tags);
|
return _bundleServices.GetAssetInfos(tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取调试信息
|
/// 获取资源信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static void GetDebugReport(DebugReport report)
|
/// <param name="tags">资源标签列表</param>
|
||||||
|
public static AssetInfo[] GetAssetInfos(string[] tags)
|
||||||
{
|
{
|
||||||
if (report == null)
|
DebugCheckInitialize();
|
||||||
YooLogger.Error($"{nameof(DebugReport)} is null");
|
return _bundleServices.GetAssetInfos(tags);
|
||||||
|
|
||||||
AssetSystem.GetDebugReport(report);
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 场景加载
|
#region 场景加载
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -363,6 +427,7 @@ namespace YooAsset
|
|||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
string scenePath = _locationServices.ConvertLocationToAssetPath(location);
|
string scenePath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
||||||
return handle;
|
return handle;
|
||||||
@@ -377,6 +442,7 @@ namespace YooAsset
|
|||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
string scenePath = assetInfo.AssetPath;
|
string scenePath = assetInfo.AssetPath;
|
||||||
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
||||||
return handle;
|
return handle;
|
||||||
@@ -391,6 +457,7 @@ namespace YooAsset
|
|||||||
/// <param name="copyPath">拷贝路径</param>
|
/// <param name="copyPath">拷贝路径</param>
|
||||||
public static RawFileOperation GetRawFileAsync(string location, string copyPath = null)
|
public static RawFileOperation GetRawFileAsync(string location, string copyPath = null)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
return GetRawFileInternal(assetPath, copyPath);
|
return GetRawFileInternal(assetPath, copyPath);
|
||||||
}
|
}
|
||||||
@@ -402,144 +469,17 @@ namespace YooAsset
|
|||||||
/// <param name="copyPath">拷贝路径</param>
|
/// <param name="copyPath">拷贝路径</param>
|
||||||
public static RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
public static RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
return GetRawFileInternal(assetInfo.AssetPath, copyPath);
|
return GetRawFileInternal(assetInfo.AssetPath, copyPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 同步加载资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetInfo">资源信息</param>
|
|
||||||
public static AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
|
||||||
{
|
|
||||||
return LoadAssetInternal(assetInfo.AssetPath, assetInfo.AssetType, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 同步加载资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
|
||||||
/// <param name="location">资源的定位地址</param>
|
|
||||||
public static AssetOperationHandle LoadAssetSync<TObject>(string location) where TObject : class
|
|
||||||
{
|
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
|
||||||
return LoadAssetInternal(assetPath, typeof(TObject), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 同步加载资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="location">资源的定位地址</param>
|
|
||||||
/// <param name="type">资源类型</param>
|
|
||||||
public static AssetOperationHandle LoadAssetSync(string location, System.Type type)
|
|
||||||
{
|
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
|
||||||
return LoadAssetInternal(assetPath, type, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 同步加载子资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetInfo">资源信息</param>
|
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
|
||||||
{
|
|
||||||
return LoadSubAssetsInternal(assetInfo.AssetPath, assetInfo.AssetType, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 同步加载子资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
|
||||||
/// <param name="location">资源的定位地址</param>
|
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsSync<TObject>(string location)
|
|
||||||
{
|
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
|
||||||
return LoadSubAssetsInternal(assetPath, typeof(TObject), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 同步加载子资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="location">资源的定位地址</param>
|
|
||||||
/// <param name="type">子对象类型</param>
|
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsSync(string location, System.Type type)
|
|
||||||
{
|
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
|
||||||
return LoadSubAssetsInternal(assetPath, type, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetInfo">资源信息</param>
|
|
||||||
public static AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
|
||||||
{
|
|
||||||
return LoadAssetInternal(assetInfo.AssetPath, assetInfo.AssetType, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
|
||||||
/// <param name="location">资源的定位地址</param>
|
|
||||||
public static AssetOperationHandle LoadAssetAsync<TObject>(string location)
|
|
||||||
{
|
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
|
||||||
return LoadAssetInternal(assetPath, typeof(TObject), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="location">资源的定位地址</param>
|
|
||||||
/// <param name="type">资源类型</param>
|
|
||||||
public static AssetOperationHandle LoadAssetAsync(string location, System.Type type)
|
|
||||||
{
|
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
|
||||||
return LoadAssetInternal(assetPath, type, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载子资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetInfo">资源信息</param>
|
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
|
||||||
{
|
|
||||||
return LoadSubAssetsInternal(assetInfo.AssetPath, assetInfo.AssetType, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载子资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
|
||||||
/// <param name="location">资源的定位地址</param>
|
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsAsync<TObject>(string location)
|
|
||||||
{
|
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
|
||||||
return LoadSubAssetsInternal(assetPath, typeof(TObject), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载子资源对象
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="location">资源的定位地址</param>
|
|
||||||
/// <param name="type">子对象类型</param>
|
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(string location, System.Type type)
|
|
||||||
{
|
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
|
||||||
return LoadSubAssetsInternal(assetPath, type, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static RawFileOperation GetRawFileInternal(string assetPath, string copyPath)
|
private static RawFileOperation GetRawFileInternal(string assetPath, string copyPath)
|
||||||
{
|
{
|
||||||
string bundleName = _bundleServices.GetBundleName(assetPath);
|
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(bundleName);
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(bundleName);
|
||||||
|
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
@@ -562,6 +502,79 @@ namespace YooAsset
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 资源加载
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetInfo">资源信息</param>
|
||||||
|
public static AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
return LoadAssetInternal(assetInfo.AssetPath, assetInfo.AssetType, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public static AssetOperationHandle LoadAssetSync<TObject>(string location) where TObject : class
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
|
return LoadAssetInternal(assetPath, typeof(TObject), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
/// <param name="type">资源类型</param>
|
||||||
|
public static AssetOperationHandle LoadAssetSync(string location, System.Type type)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
|
return LoadAssetInternal(assetPath, type, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetInfo">资源信息</param>
|
||||||
|
public static AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
return LoadAssetInternal(assetInfo.AssetPath, assetInfo.AssetType, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public static AssetOperationHandle LoadAssetAsync<TObject>(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
|
return LoadAssetInternal(assetPath, typeof(TObject), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
/// <param name="type">资源类型</param>
|
||||||
|
public static AssetOperationHandle LoadAssetAsync(string location, System.Type type)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
|
return LoadAssetInternal(assetPath, type, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static AssetOperationHandle LoadAssetInternal(string assetPath, System.Type assetType, bool waitForAsyncComplete)
|
private static AssetOperationHandle LoadAssetInternal(string assetPath, System.Type assetType, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
var handle = AssetSystem.LoadAssetAsync(assetPath, assetType);
|
var handle = AssetSystem.LoadAssetAsync(assetPath, assetType);
|
||||||
@@ -569,6 +582,79 @@ namespace YooAsset
|
|||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 资源加载
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载子资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetInfo">资源信息</param>
|
||||||
|
public static SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
return LoadSubAssetsInternal(assetInfo.AssetPath, assetInfo.AssetType, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载子资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public static SubAssetsOperationHandle LoadSubAssetsSync<TObject>(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
|
return LoadSubAssetsInternal(assetPath, typeof(TObject), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步加载子资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
/// <param name="type">子对象类型</param>
|
||||||
|
public static SubAssetsOperationHandle LoadSubAssetsSync(string location, System.Type type)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
|
return LoadSubAssetsInternal(assetPath, type, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载子资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetInfo">资源信息</param>
|
||||||
|
public static SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
return LoadSubAssetsInternal(assetInfo.AssetPath, assetInfo.AssetType, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载子资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public static SubAssetsOperationHandle LoadSubAssetsAsync<TObject>(string location)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
|
return LoadSubAssetsInternal(assetPath, typeof(TObject), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载子资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
/// <param name="type">子对象类型</param>
|
||||||
|
public static SubAssetsOperationHandle LoadSubAssetsAsync(string location, System.Type type)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||||
|
return LoadSubAssetsInternal(assetPath, type, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static SubAssetsOperationHandle LoadSubAssetsInternal(string assetPath, System.Type assetType, bool waitForAsyncComplete)
|
private static SubAssetsOperationHandle LoadSubAssetsInternal(string assetPath, System.Type assetType, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
var handle = AssetSystem.LoadSubAssetsAsync(assetPath, assetType);
|
var handle = AssetSystem.LoadSubAssetsAsync(assetPath, assetType);
|
||||||
@@ -587,6 +673,7 @@ namespace YooAsset
|
|||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
return CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
return CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,7 +685,8 @@ namespace YooAsset
|
|||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
@@ -623,7 +711,8 @@ namespace YooAsset
|
|||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
@@ -650,7 +739,8 @@ namespace YooAsset
|
|||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
@@ -683,7 +773,8 @@ namespace YooAsset
|
|||||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||||
public static PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
|
public static PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
@@ -717,6 +808,7 @@ namespace YooAsset
|
|||||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||||
public static PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
public static PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
return CreatePatchUnpacker(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
|
return CreatePatchUnpacker(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,7 +820,8 @@ namespace YooAsset
|
|||||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||||
public static PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
public static PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||||
@@ -761,7 +854,8 @@ namespace YooAsset
|
|||||||
/// <param name="timeout">超时时间</param>
|
/// <param name="timeout">超时时间</param>
|
||||||
public static UpdatePackageOperation UpdatePackageAsync(int resourceVersion, int timeout = 60)
|
public static UpdatePackageOperation UpdatePackageAsync(int resourceVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeUpdatePackageOperation();
|
var operation = new EditorPlayModeUpdatePackageOperation();
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
@@ -833,21 +927,33 @@ namespace YooAsset
|
|||||||
// 轮询更新资源系统
|
// 轮询更新资源系统
|
||||||
AssetSystem.Update();
|
AssetSystem.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源定位地址转换为资源完整路径
|
||||||
|
/// </summary>
|
||||||
internal static string MappingToAssetPath(string location)
|
internal static string MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
DebugCheckLocation(location);
|
||||||
CheckLocation(location);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return _bundleServices.MappingToAssetPath(location);
|
return _bundleServices.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#region 调试方法
|
||||||
private static void CheckLocation(string location)
|
[Conditional("DEBUG")]
|
||||||
|
private static void DebugCheckInitialize()
|
||||||
|
{
|
||||||
|
if (_initializeStatus == EOperationStatus.None)
|
||||||
|
throw new Exception("YooAssets initialize not completed !");
|
||||||
|
else if (_initializeStatus == EOperationStatus.Failed)
|
||||||
|
throw new Exception($"YooAssets initialize failed : {_initializeError}");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Conditional("DEBUG")]
|
||||||
|
private static void DebugCheckLocation(string location)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(location))
|
if (string.IsNullOrEmpty(location))
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError("location param is null or empty!");
|
YooLogger.Error("location param is null or empty!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -856,14 +962,13 @@ namespace YooAsset
|
|||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
if (location.Length == index + 1)
|
if (location.Length == index + 1)
|
||||||
UnityEngine.Debug.LogWarning($"Found blank character in location : \"{location}\"");
|
YooLogger.Warning($"Found blank character in location : \"{location}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.IndexOfAny(System.IO.Path.GetInvalidPathChars()) >= 0)
|
if (location.IndexOfAny(System.IO.Path.GetInvalidPathChars()) >= 0)
|
||||||
UnityEngine.Debug.LogWarning($"Found illegal character in location : \"{location}\"");
|
YooLogger.Warning($"Found illegal character in location : \"{location}\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.0.7",
|
"version": "1.0.8",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system",
|
"description": "unity3d resources management system",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
- **Build Mode**
|
- **Build Mode**
|
||||||
|
|
||||||
构建模式:强制构建模式,增量构建模式,快速构建模式,演练构建模式。
|
构建模式:强制构建模式,增量构建模式,演练构建模式,模拟构建模式。
|
||||||
|
|
||||||
- **Encryption**
|
- **Encryption**
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ YooAssets.InitializeAsync(CreateParameters parameters);
|
|||||||
````c#
|
````c#
|
||||||
private IEnumerator InitializeYooAsset()
|
private IEnumerator InitializeYooAsset()
|
||||||
{
|
{
|
||||||
var createParameters = new YooAssets.EditorPlayModeParameters();
|
var createParameters = new YooAssets.EditorSimulateModeParameters();
|
||||||
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||||
yield return YooAssets.InitializeAsync(createParameters);
|
yield return YooAssets.InitializeAsync(createParameters);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user