mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-15 12:10:09 +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.
|
||||
|
||||
## [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
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace YooAsset.Editor
|
||||
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
||||
if (parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
|
||||
else if(parameters.BuildMode == EBuildMode.FastRunBuild)
|
||||
PipelineOutputDirectory += $"_{EBuildMode.FastRunBuild}";
|
||||
else if(parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,7 +53,7 @@ namespace YooAsset.Editor
|
||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||
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 !");
|
||||
}
|
||||
@@ -89,9 +89,9 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取构建的耗时(单位:秒)
|
||||
/// </summary>
|
||||
public int GetBuildingSeconds()
|
||||
public float GetBuildingSeconds()
|
||||
{
|
||||
int seconds = (int)(_buildWatch.ElapsedMilliseconds / 1000);
|
||||
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
||||
return seconds;
|
||||
}
|
||||
public void BeginWatch()
|
||||
@@ -132,16 +132,16 @@ namespace YooAsset.Editor
|
||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||
};
|
||||
|
||||
if (buildParameters.BuildMode == EBuildMode.FastRunBuild)
|
||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
BuildRunner.EnableLog = false;
|
||||
else
|
||||
BuildRunner.EnableLog = true;
|
||||
|
||||
bool succeed = BuildRunner.Run(pipeline, _buildContext);
|
||||
if (succeed)
|
||||
Debug.Log($"{buildParameters.BuildMode}模式构建成功!");
|
||||
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||
else
|
||||
Debug.LogWarning($"{buildParameters.BuildMode}模式构建失败!");
|
||||
Debug.LogWarning($"{buildParameters.BuildMode} pipeline build failed !");
|
||||
return succeed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildVersion = _buildVersionField.value;
|
||||
buildParameters.BuildinTags = _buildTagsField.value;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
buildParameters.AppendFileExtension = _appendExtensionToggle.value;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.CompressOption = (ECompressOption)_compressionField.value;
|
||||
@@ -199,9 +199,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private List<Type> GetEncryptionServicesClassTypes()
|
||||
{
|
||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IEncryptionServices>();
|
||||
List<Type> classTypes = collection.ToList();
|
||||
return classTypes;
|
||||
return EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
}
|
||||
private IEncryptionServices CreateEncryptionServicesInstance()
|
||||
{
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleRuntimeBuilder
|
||||
public static class AssetBundleSimulateBuilder
|
||||
{
|
||||
private static string _manifestFilePath = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 快速模式构建
|
||||
/// 模拟构建
|
||||
/// </summary>
|
||||
public static void FastBuild()
|
||||
public static void SimulateBuild()
|
||||
{
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
BuildParameters buildParameters = new BuildParameters();
|
||||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.FastRunBuild;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
|
||||
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
|
||||
buildParameters.EnableAddressable = AssetBundleGrouperSettingData.Setting.EnableAddressable;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
bool buildResult = builder.Run(buildParameters);
|
||||
if (buildResult)
|
||||
{
|
||||
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
|
||||
{
|
||||
@@ -35,9 +34,9 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的补丁清单文件路径
|
||||
/// 获取构建的补丁清单路径
|
||||
/// </summary>
|
||||
public static string GetPatchManifestFilePath()
|
||||
public static string GetPatchManifestPath()
|
||||
{
|
||||
return _manifestFilePath;
|
||||
}
|
||||
@@ -147,11 +147,11 @@ namespace YooAsset.Editor
|
||||
if (IsRawAsset)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||
{
|
||||
if (IsShaderAsset)
|
||||
{
|
||||
string shareBundleName = $"{AssetBundleGrouperSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||
string shareBundleName = $"{AssetBundleCollectorSettingData.Setting.ShadersBundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,16 +10,16 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 执行资源构建上下文
|
||||
/// </summary>
|
||||
public static BuildMapContext CreateBuildMap()
|
||||
public static BuildMapContext CreateBuildMap(EBuildMode buildMode)
|
||||
{
|
||||
BuildMapContext context = new BuildMapContext();
|
||||
Dictionary<string, BuildAssetInfo> buildAssetDic = new Dictionary<string, BuildAssetInfo>(1000);
|
||||
|
||||
// 1. 检测配置合法性
|
||||
AssetBundleGrouperSettingData.Setting.CheckConfigError();
|
||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||
|
||||
// 2. 获取所有主动收集的资源
|
||||
List<CollectAssetInfo> allCollectAssets = AssetBundleGrouperSettingData.Setting.GetAllCollectAssets();
|
||||
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(buildMode);
|
||||
|
||||
// 3. 剔除未被引用的依赖资源
|
||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||
|
||||
@@ -8,6 +8,21 @@ namespace YooAsset.Editor
|
||||
[Serializable]
|
||||
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>
|
||||
@@ -38,6 +53,26 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
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()
|
||||
{
|
||||
if (Tags != null)
|
||||
@@ -45,5 +80,16 @@ namespace YooAsset.Editor
|
||||
else
|
||||
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>
|
||||
public static void Log(string info)
|
||||
{
|
||||
if (EnableLog)
|
||||
{
|
||||
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 buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
// 快速构建模式下跳过引擎构建
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.FastRunBuild)
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
BuildAssetBundleOptions opt = buildParametersContext.GetPipelineBuildOptions();
|
||||
|
||||
@@ -12,20 +12,30 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||
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)
|
||||
{
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||
BuildReport buildReport = new BuildReport();
|
||||
buildParameters.StopWatch();
|
||||
BuildReport buildReport = new BuildReport();
|
||||
|
||||
// 概述信息
|
||||
{
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
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.BuildMode = buildParameters.Parameters.BuildMode;
|
||||
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
|
||||
@@ -33,8 +43,8 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
|
||||
buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
|
||||
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
|
||||
buildReport.Summary.AutoCollectShaders = AssetBundleGrouperSettingData.Setting.AutoCollectShaders;
|
||||
buildReport.Summary.ShadersBundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
||||
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
|
||||
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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);
|
||||
BuildRunner.Log("构建内容准备完毕!");
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||
|
||||
// 快速构建模式下跳过验证
|
||||
if (buildParametersContext.Parameters.BuildMode == EBuildMode.FastRunBuild)
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 验证构建结果
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
IncrementalBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 快速构建模式
|
||||
/// </summary>
|
||||
FastRunBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 演练构建模式
|
||||
/// </summary>
|
||||
DryRunBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
SimulateBuild,
|
||||
}
|
||||
}
|
||||
@@ -51,13 +51,13 @@ namespace YooAsset.Editor
|
||||
if (CollectorType == ECollectorType.None)
|
||||
return false;
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
return false;
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
return false;
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -74,21 +74,28 @@ namespace YooAsset.Editor
|
||||
if (CollectorType == ECollectorType.None)
|
||||
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}");
|
||||
|
||||
if (AssetBundleGrouperSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
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}");
|
||||
}
|
||||
|
||||
/// <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);
|
||||
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}");
|
||||
|
||||
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))
|
||||
@@ -110,7 +117,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
if (result.ContainsKey(assetPath) == false)
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(grouper, assetPath, isRawAsset);
|
||||
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
@@ -125,7 +132,7 @@ namespace YooAsset.Editor
|
||||
string assetPath = CollectPath;
|
||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(grouper, assetPath, isRawAsset);
|
||||
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
@@ -135,7 +142,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (AssetBundleGrouperSettingData.Setting.EnableAddressable)
|
||||
if (AssetBundleCollectorSettingData.Setting.EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
@@ -155,11 +162,11 @@ namespace YooAsset.Editor
|
||||
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 bundleName = GetBundleName(grouper, assetPath);
|
||||
List<string> assetTags = GetAssetTags(grouper);
|
||||
string address = GetAddress(group, assetPath);
|
||||
string bundleName = GetBundleName(group, assetPath);
|
||||
List<string> assetTags = GetAssetTags(group);
|
||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||
return collectAssetInfo;
|
||||
@@ -186,7 +193,7 @@ namespace YooAsset.Editor
|
||||
private bool IsCollectAsset(string assetPath)
|
||||
{
|
||||
// 如果收集全路径着色器
|
||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
||||
if (AssetBundleCollectorSettingData.Setting.AutoCollectShaders)
|
||||
{
|
||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
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));
|
||||
}
|
||||
private string GetAddress(AssetBundleGrouper grouper, string assetPath)
|
||||
private string GetAddress(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return string.Empty;
|
||||
|
||||
IAddressRule addressRuleInstance = AssetBundleGrouperSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, grouper.GrouperName));
|
||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName));
|
||||
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);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
{
|
||||
string bundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
||||
string bundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
|
||||
return EditorTools.GetRegularPath(bundleName).ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
// 根据规则设置获取资源包名称
|
||||
{
|
||||
IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName);
|
||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName));
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, group.GroupName));
|
||||
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, ';');
|
||||
tags.AddRange(temper);
|
||||
return tags;
|
||||
}
|
||||
private List<string> GetAllDependencies(string mainAssetPath)
|
||||
{
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if(AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild)
|
||||
return new List<string>();
|
||||
|
||||
List<string> result = new List<string>();
|
||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||
foreach (string assetPath in depends)
|
||||
@@ -8,14 +8,18 @@ using UnityEngine;
|
||||
|
||||
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 XmlShaderBundleName = "ShaderBundleName";
|
||||
public const string XmlGrouper = "Grouper";
|
||||
public const string XmlGrouperName = "GrouperName";
|
||||
public const string XmlGrouperDesc = "GrouperDesc";
|
||||
public const string XmlGroup = "Group";
|
||||
public const string XmlGroupName = "GroupName";
|
||||
public const string XmlGroupDesc = "GroupDesc";
|
||||
public const string XmlCollector = "Collector";
|
||||
public const string XmlCollectPath = "CollectPath";
|
||||
public const string XmlCollectorType = "CollectType";
|
||||
@@ -40,43 +44,54 @@ namespace YooAsset.Editor
|
||||
xml.Load(filePath);
|
||||
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;
|
||||
string shaderBundleName = string.Empty;
|
||||
var shaderNodeList = root.GetElementsByTagName(XmlShader);
|
||||
if (shaderNodeList.Count > 0)
|
||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||
if (commonNodeList.Count > 0)
|
||||
{
|
||||
XmlElement shaderElement = shaderNodeList[0] as XmlElement;
|
||||
if (shaderElement.HasAttribute(XmlAutoCollectShader) == false)
|
||||
throw new Exception($"Not found attribute {XmlAutoCollectShader} in {XmlShader}");
|
||||
if (shaderElement.HasAttribute(XmlShaderBundleName) == false)
|
||||
throw new Exception($"Not found attribute {XmlShaderBundleName} in {XmlShader}");
|
||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
||||
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
||||
if (commonElement.HasAttribute(XmlAutoCollectShader) == false)
|
||||
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;
|
||||
shaderBundleName = shaderElement.GetAttribute(XmlShaderBundleName);
|
||||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||
autoCollectShaders = commonElement.GetAttribute(XmlAutoCollectShader) == "True" ? true : false;
|
||||
shaderBundleName = commonElement.GetAttribute(XmlShaderBundleName);
|
||||
}
|
||||
|
||||
// 读取分组配置
|
||||
List<AssetBundleGrouper> grouperTemper = new List<AssetBundleGrouper>();
|
||||
var grouperNodeList = root.GetElementsByTagName(XmlGrouper);
|
||||
foreach (var grouperNode in grouperNodeList)
|
||||
List<AssetBundleCollectorGroup> groupTemper = new List<AssetBundleCollectorGroup>();
|
||||
var groupNodeList = root.GetElementsByTagName(XmlGroup);
|
||||
foreach (var groupNode in groupNodeList)
|
||||
{
|
||||
XmlElement grouperElement = grouperNode as XmlElement;
|
||||
if (grouperElement.HasAttribute(XmlGrouperName) == false)
|
||||
throw new Exception($"Not found attribute {XmlGrouperName} in {XmlGrouper}");
|
||||
if (grouperElement.HasAttribute(XmlGrouperDesc) == false)
|
||||
throw new Exception($"Not found attribute {XmlGrouperDesc} in {XmlGrouper}");
|
||||
if (grouperElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGrouper}");
|
||||
XmlElement groupElement = groupNode as XmlElement;
|
||||
if (groupElement.HasAttribute(XmlGroupName) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlGroupDesc) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
|
||||
|
||||
AssetBundleGrouper grouper = new AssetBundleGrouper();
|
||||
grouper.GrouperName = grouperElement.GetAttribute(XmlGrouperName);
|
||||
grouper.GrouperDesc = grouperElement.GetAttribute(XmlGrouperDesc);
|
||||
grouper.AssetTags = grouperElement.GetAttribute(XmlAssetTags);
|
||||
grouperTemper.Add(grouper);
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupElement.GetAttribute(XmlGroupName);
|
||||
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
|
||||
group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
|
||||
groupTemper.Add(group);
|
||||
|
||||
// 读取收集器配置
|
||||
var collectorNodeList = grouperElement.GetElementsByTagName(XmlCollector);
|
||||
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||
foreach (var collectorNode in collectorNodeList)
|
||||
{
|
||||
XmlElement collectorElement = collectorNode as XmlElement;
|
||||
@@ -100,16 +115,17 @@ namespace YooAsset.Editor
|
||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags); ;
|
||||
grouper.Collectors.Add(collector);
|
||||
group.Collectors.Add(collector);
|
||||
}
|
||||
}
|
||||
|
||||
// 保存配置数据
|
||||
AssetBundleGrouperSettingData.ClearAll();
|
||||
AssetBundleGrouperSettingData.Setting.AutoCollectShaders = autoCollectShaders;
|
||||
AssetBundleGrouperSettingData.Setting.ShadersBundleName = shaderBundleName;
|
||||
AssetBundleGrouperSettingData.Setting.Groupers.AddRange(grouperTemper);
|
||||
AssetBundleGrouperSettingData.SaveFile();
|
||||
AssetBundleCollectorSettingData.ClearAll();
|
||||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||
AssetBundleCollectorSettingData.Setting.AutoCollectShaders = autoCollectShaders;
|
||||
AssetBundleCollectorSettingData.Setting.ShadersBundleName = shaderBundleName;
|
||||
AssetBundleCollectorSettingData.Setting.Groups.AddRange(groupTemper);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
Debug.Log($"导入配置完毕!");
|
||||
}
|
||||
|
||||
@@ -130,22 +146,27 @@ namespace YooAsset.Editor
|
||||
xmlDoc.LoadXml(sb.ToString());
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
|
||||
// 设置着色器配置
|
||||
var shaderElement = xmlDoc.CreateElement(XmlShader);
|
||||
shaderElement.SetAttribute(XmlAutoCollectShader, AssetBundleGrouperSettingData.Setting.AutoCollectShaders.ToString());
|
||||
shaderElement.SetAttribute(XmlShaderBundleName, AssetBundleGrouperSettingData.Setting.ShadersBundleName);
|
||||
// 设置配置版本
|
||||
root.SetAttribute(XmlVersion, ConfigVersion);
|
||||
|
||||
// 设置公共配置
|
||||
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);
|
||||
grouperElement.SetAttribute(XmlGrouperName, grouper.GrouperName);
|
||||
grouperElement.SetAttribute(XmlGrouperDesc, grouper.GrouperDesc);
|
||||
grouperElement.SetAttribute(XmlAssetTags, grouper.AssetTags);
|
||||
root.AppendChild(grouperElement);
|
||||
var groupElement = xmlDoc.CreateElement(XmlGroup);
|
||||
groupElement.SetAttribute(XmlGroupName, group.GroupName);
|
||||
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
|
||||
groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
|
||||
root.AppendChild(groupElement);
|
||||
|
||||
// 设置收集器配置
|
||||
foreach (var collector in grouper.Collectors)
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
||||
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
||||
@@ -154,7 +175,7 @@ namespace YooAsset.Editor
|
||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||
grouperElement.AppendChild(collectorElement);
|
||||
groupElement.AppendChild(collectorElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,17 +8,17 @@ using UnityEditor;
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetBundleGrouper
|
||||
public class AssetBundleCollectorGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// 分组名称
|
||||
/// </summary>
|
||||
public string GrouperName = string.Empty;
|
||||
public string GroupName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 分组描述
|
||||
/// </summary>
|
||||
public string GrouperDesc = string.Empty;
|
||||
public string GroupDesc = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
@@ -58,12 +58,12 @@ namespace YooAsset.Editor
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
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>();
|
||||
foreach (var collectInfoPair in result)
|
||||
@@ -74,7 +74,7 @@ namespace YooAsset.Editor
|
||||
if (adressTemper.Contains(address) == false)
|
||||
adressTemper.Add(address);
|
||||
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
|
||||
{
|
||||
public class AssetBundleGrouperSetting : ScriptableObject
|
||||
public class AssetBundleCollectorSetting : ScriptableObject
|
||||
{
|
||||
public static EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用可寻址资源定位
|
||||
/// </summary>
|
||||
@@ -26,7 +28,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 分组列表
|
||||
/// </summary>
|
||||
public List<AssetBundleGrouper> Groupers = new List<AssetBundleGrouper>();
|
||||
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -34,29 +36,31 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
foreach (var grouper in Groupers)
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
grouper.CheckConfigError();
|
||||
group.CheckConfigError();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets()
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode)
|
||||
{
|
||||
BuildMode = buildMode;
|
||||
|
||||
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)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
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)
|
||||
adressTemper.Add(address);
|
||||
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
|
||||
{
|
||||
public class AssetBundleGrouperSettingData
|
||||
public class AssetBundleCollectorSettingData
|
||||
{
|
||||
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
||||
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;
|
||||
|
||||
|
||||
private static AssetBundleGrouperSetting _setting = null;
|
||||
public static AssetBundleGrouperSetting Setting
|
||||
private static AssetBundleCollectorSetting _setting = null;
|
||||
public static AssetBundleCollectorSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -106,12 +106,12 @@ namespace YooAsset.Editor
|
||||
private static void LoadSettingData()
|
||||
{
|
||||
// 加载配置文件
|
||||
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleGrouperSetting)}.asset";
|
||||
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleGrouperSetting>(settingFilePath);
|
||||
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleCollectorSetting)}.asset";
|
||||
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleCollectorSetting>(settingFilePath);
|
||||
if (_setting == null)
|
||||
{
|
||||
Debug.LogWarning($"Create new {nameof(AssetBundleGrouperSetting)}.asset : {settingFilePath}");
|
||||
_setting = ScriptableObject.CreateInstance<AssetBundleGrouperSetting>();
|
||||
Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {settingFilePath}");
|
||||
_setting = ScriptableObject.CreateInstance<AssetBundleCollectorSetting>();
|
||||
EditorTools.CreateFileDirectory(settingFilePath);
|
||||
AssetDatabase.CreateAsset(Setting, settingFilePath);
|
||||
AssetDatabase.SaveAssets();
|
||||
@@ -119,7 +119,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"Load {nameof(AssetBundleGrouperSetting)}.asset ok");
|
||||
Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok");
|
||||
}
|
||||
|
||||
// IPackRule
|
||||
@@ -135,12 +135,11 @@ namespace YooAsset.Editor
|
||||
typeof(PackDirectory),
|
||||
typeof(PackTopDirectory),
|
||||
typeof(PackCollector),
|
||||
typeof(PackGrouper),
|
||||
typeof(PackGroup),
|
||||
typeof(PackRawFile),
|
||||
};
|
||||
|
||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IPackRule>();
|
||||
var customTypes = collection.ToList();
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
@@ -165,8 +164,7 @@ namespace YooAsset.Editor
|
||||
typeof(CollectSprite)
|
||||
};
|
||||
|
||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IFilterRule>();
|
||||
var customTypes = collection.ToList();
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IFilterRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
@@ -187,11 +185,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
typeof(AddressByFileName),
|
||||
typeof(AddressByCollectorAndFileName),
|
||||
typeof(AddressByGrouperAndFileName)
|
||||
typeof(AddressByGroupAndFileName)
|
||||
};
|
||||
|
||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IAddressRule>();
|
||||
var customTypes = collection.ToList();
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
@@ -212,7 +209,7 @@ namespace YooAsset.Editor
|
||||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
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.ShadersBundleName = string.Empty;
|
||||
Setting.Groupers.Clear();
|
||||
Setting.Groups.Clear();
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
@@ -296,43 +293,43 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 资源分组编辑相关
|
||||
public static void CreateGrouper(string grouperName)
|
||||
public static void CreateGroup(string groupName)
|
||||
{
|
||||
AssetBundleGrouper grouper = new AssetBundleGrouper();
|
||||
grouper.GrouperName = grouperName;
|
||||
Setting.Groupers.Add(grouper);
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupName;
|
||||
Setting.Groups.Add(group);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// 资源收集器编辑相关
|
||||
public static void CreateCollector(AssetBundleGrouper grouper, string collectPath)
|
||||
public static void CreateCollector(AssetBundleCollectorGroup group, string collectPath)
|
||||
{
|
||||
AssetBundleCollector collector = new AssetBundleCollector();
|
||||
collector.CollectPath = collectPath;
|
||||
grouper.Collectors.Add(collector);
|
||||
group.Collectors.Add(collector);
|
||||
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;
|
||||
}
|
||||
@@ -341,9 +338,9 @@ namespace YooAsset.Editor
|
||||
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;
|
||||
}
|
||||
@@ -9,12 +9,12 @@ using UnityEngine.UIElements;
|
||||
|
||||
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()
|
||||
{
|
||||
AssetBundleGrouperWindow window = GetWindow<AssetBundleGrouperWindow>("资源包分组工具", true, EditorDefine.DockedWindowTypes);
|
||||
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, EditorDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ namespace YooAsset.Editor
|
||||
private List<string> _addressRuleList;
|
||||
private List<string> _packRuleList;
|
||||
private List<string> _filterRuleList;
|
||||
private ListView _grouperListView;
|
||||
private ListView _groupListView;
|
||||
private ScrollView _collectorScrollView;
|
||||
private Toggle _enableAddressableToogle;
|
||||
private Toggle _autoCollectShaderToogle;
|
||||
private TextField _shaderBundleNameTxt;
|
||||
private TextField _grouperNameTxt;
|
||||
private TextField _grouperDescTxt;
|
||||
private TextField _grouperAssetTagsTxt;
|
||||
private VisualElement _grouperContainer;
|
||||
private TextField _groupNameTxt;
|
||||
private TextField _groupDescTxt;
|
||||
private TextField _groupAssetTagsTxt;
|
||||
private VisualElement _groupContainer;
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
@@ -45,17 +45,17 @@ namespace YooAsset.Editor
|
||||
$"{nameof(ECollectorType.StaticAssetCollector)}",
|
||||
$"{nameof(ECollectorType.DependAssetCollector)}"
|
||||
};
|
||||
_addressRuleList = AssetBundleGrouperSettingData.GetAddressRuleNames();
|
||||
_packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames();
|
||||
_filterRuleList = AssetBundleGrouperSettingData.GetFilterRuleNames();
|
||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||
|
||||
// 加载布局文件
|
||||
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);
|
||||
if (visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(AssetBundleGrouperWindow)}.uxml : {uxml}");
|
||||
Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml : {uxml}");
|
||||
return;
|
||||
}
|
||||
visualAsset.CloneTree(root);
|
||||
@@ -72,75 +72,75 @@ namespace YooAsset.Editor
|
||||
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
|
||||
_enableAddressableToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleGrouperSettingData.ModifyAddressable(evt.newValue);
|
||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||
});
|
||||
_autoCollectShaderToogle = root.Q<Toggle>("AutoCollectShader");
|
||||
_autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleGrouperSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
||||
AssetBundleCollectorSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
||||
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
||||
});
|
||||
_shaderBundleNameTxt = root.Q<TextField>("ShaderBundleName");
|
||||
_shaderBundleNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleGrouperSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue);
|
||||
AssetBundleCollectorSettingData.ModifyShader(_autoCollectShaderToogle.value, evt.newValue);
|
||||
});
|
||||
|
||||
// 分组列表相关
|
||||
_grouperListView = root.Q<ListView>("GrouperListView");
|
||||
_grouperListView.makeItem = MakeGrouperListViewItem;
|
||||
_grouperListView.bindItem = BindGrouperListViewItem;
|
||||
_groupListView = root.Q<ListView>("GroupListView");
|
||||
_groupListView.makeItem = MakeGroupListViewItem;
|
||||
_groupListView.bindItem = BindGroupListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_grouperListView.onSelectionChange += GrouperListView_onSelectionChange;
|
||||
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
|
||||
#else
|
||||
_grouperListView.onSelectionChanged += GrouperListView_onSelectionChange;
|
||||
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 分组添加删除按钮
|
||||
var grouperAddContainer = root.Q("GrouperAddContainer");
|
||||
var groupAddContainer = root.Q("GroupAddContainer");
|
||||
{
|
||||
var addBtn = grouperAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddGrouperBtn_clicked;
|
||||
var removeBtn = grouperAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveGrouperBtn_clicked;
|
||||
var addBtn = groupAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddGroupBtn_clicked;
|
||||
var removeBtn = groupAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveGroupBtn_clicked;
|
||||
}
|
||||
|
||||
// 分组容器
|
||||
_grouperContainer = root.Q("GrouperContainer");
|
||||
_groupContainer = root.Q("GroupContainer");
|
||||
|
||||
// 分组名称
|
||||
_grouperNameTxt = root.Q<TextField>("GrouperName");
|
||||
_grouperNameTxt.RegisterValueChangedCallback(evt =>
|
||||
_groupNameTxt = root.Q<TextField>("GroupName");
|
||||
_groupNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper != null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGrouper.GrouperName = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
||||
selectGroup.GroupName = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
// 分组备注
|
||||
_grouperDescTxt = root.Q<TextField>("GrouperDesc");
|
||||
_grouperDescTxt.RegisterValueChangedCallback(evt =>
|
||||
_groupDescTxt = root.Q<TextField>("GroupDesc");
|
||||
_groupDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper != null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGrouper.GrouperDesc = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
||||
selectGroup.GroupDesc = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
// 分组的资源标签
|
||||
_grouperAssetTagsTxt = root.Q<TextField>("GrouperAssetTags");
|
||||
_grouperAssetTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
_groupAssetTagsTxt = root.Q<TextField>("GroupAssetTags");
|
||||
_groupAssetTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper != null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup != null)
|
||||
{
|
||||
selectGrouper.AssetTags = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyGrouper(selectGrouper);
|
||||
selectGroup.AssetTags = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -166,26 +166,26 @@ namespace YooAsset.Editor
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (AssetBundleGrouperSettingData.IsDirty)
|
||||
AssetBundleGrouperSettingData.SaveFile();
|
||||
if (AssetBundleCollectorSettingData.IsDirty)
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
}
|
||||
|
||||
private void RefreshWindow()
|
||||
{
|
||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.EnableAddressable);
|
||||
_autoCollectShaderToogle.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetEnabled(AssetBundleGrouperSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetValueWithoutNotify(AssetBundleGrouperSettingData.Setting.ShadersBundleName);
|
||||
_grouperContainer.visible = false;
|
||||
_enableAddressableToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.EnableAddressable);
|
||||
_autoCollectShaderToogle.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetEnabled(AssetBundleCollectorSettingData.Setting.AutoCollectShaders);
|
||||
_shaderBundleNameTxt.SetValueWithoutNotify(AssetBundleCollectorSettingData.Setting.ShadersBundleName);
|
||||
_groupContainer.visible = false;
|
||||
|
||||
FillGrouperViewData();
|
||||
FillGroupViewData();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export XML", "Assets/");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetBundleGrouperConfig.ExportXmlConfig($"{resultPath}/{nameof(AssetBundleGrouperConfig)}.xml");
|
||||
AssetBundleCollectorConfig.ExportXmlConfig($"{resultPath}/{nameof(AssetBundleCollectorConfig)}.xml");
|
||||
}
|
||||
}
|
||||
private void ImportBtn_clicked()
|
||||
@@ -193,20 +193,20 @@ namespace YooAsset.Editor
|
||||
string resultPath = EditorTools.OpenFilePath("Import XML", "Assets/", "xml");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetBundleGrouperConfig.ImportXmlConfig(resultPath);
|
||||
AssetBundleCollectorConfig.ImportXmlConfig(resultPath);
|
||||
RefreshWindow();
|
||||
}
|
||||
}
|
||||
|
||||
// 分组列表相关
|
||||
private void FillGrouperViewData()
|
||||
private void FillGroupViewData()
|
||||
{
|
||||
_grouperListView.Clear();
|
||||
_grouperListView.ClearSelection();
|
||||
_grouperListView.itemsSource = AssetBundleGrouperSettingData.Setting.Groupers;
|
||||
_grouperListView.Rebuild();
|
||||
_groupListView.Clear();
|
||||
_groupListView.ClearSelection();
|
||||
_groupListView.itemsSource = AssetBundleCollectorSettingData.Setting.Groups;
|
||||
_groupListView.Rebuild();
|
||||
}
|
||||
private VisualElement MakeGrouperListViewItem()
|
||||
private VisualElement MakeGroupListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
@@ -221,57 +221,57 @@ namespace YooAsset.Editor
|
||||
|
||||
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");
|
||||
if (string.IsNullOrEmpty(grouper.GrouperDesc))
|
||||
textField1.text = grouper.GrouperName;
|
||||
if (string.IsNullOrEmpty(group.GroupDesc))
|
||||
textField1.text = group.GroupName;
|
||||
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();
|
||||
}
|
||||
private void AddGrouperBtn_clicked()
|
||||
private void AddGroupBtn_clicked()
|
||||
{
|
||||
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset AddGrouper");
|
||||
AssetBundleGrouperSettingData.CreateGrouper("Default Grouper");
|
||||
FillGrouperViewData();
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset AddGroup");
|
||||
AssetBundleCollectorSettingData.CreateGroup("Default Group");
|
||||
FillGroupViewData();
|
||||
}
|
||||
private void RemoveGrouperBtn_clicked()
|
||||
private void RemoveGroupBtn_clicked()
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset RemoveGrouper");
|
||||
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset RemoveGroup");
|
||||
|
||||
AssetBundleGrouperSettingData.RemoveGrouper(selectGrouper);
|
||||
FillGrouperViewData();
|
||||
AssetBundleCollectorSettingData.RemoveGroup(selectGroup);
|
||||
FillGroupViewData();
|
||||
}
|
||||
|
||||
// 收集列表相关
|
||||
private void FillCollectorViewData()
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
{
|
||||
_grouperContainer.visible = false;
|
||||
_groupContainer.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_grouperContainer.visible = true;
|
||||
_grouperNameTxt.SetValueWithoutNotify(selectGrouper.GrouperName);
|
||||
_grouperDescTxt.SetValueWithoutNotify(selectGrouper.GrouperDesc);
|
||||
_grouperAssetTagsTxt.SetValueWithoutNotify(selectGrouper.AssetTags);
|
||||
_groupContainer.visible = true;
|
||||
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
|
||||
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
|
||||
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
|
||||
|
||||
// 填充数据
|
||||
_collectorScrollView.Clear();
|
||||
for (int i = 0; i < selectGrouper.Collectors.Count; i++)
|
||||
for (int i = 0; i < selectGroup.Collectors.Count; i++)
|
||||
{
|
||||
VisualElement element = MakeCollectorListViewItem();
|
||||
BindCollectorListViewItem(element, i);
|
||||
@@ -391,18 +391,24 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void BindCollectorListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
var collector = selectGrouper.Collectors[index];
|
||||
var collector = selectGroup.Collectors[index];
|
||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||
if (collectObject != null)
|
||||
collectObject.name = collector.CollectPath;
|
||||
|
||||
// Foldout
|
||||
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
|
||||
var removeBtn = element.Q<Button>("Button1");
|
||||
@@ -418,8 +424,11 @@ namespace YooAsset.Editor
|
||||
{
|
||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
objectField1.value.name = collector.CollectPath;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
// Collector Type
|
||||
@@ -428,8 +437,11 @@ namespace YooAsset.Editor
|
||||
popupField0.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.CollectorType = StringUtility.NameToEnum<ECollectorType>(evt.newValue);
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
// Address Rule
|
||||
@@ -440,8 +452,11 @@ namespace YooAsset.Editor
|
||||
popupField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.AddressRuleName = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -451,8 +466,11 @@ namespace YooAsset.Editor
|
||||
popupField2.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.PackRuleName = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
// Filter Rule
|
||||
@@ -461,8 +479,11 @@ namespace YooAsset.Editor
|
||||
popupField3.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.FilterRuleName = evt.newValue;
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
RefreshFoldout(foldout, selectGrouper, collector);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
});
|
||||
|
||||
// Tags
|
||||
@@ -471,17 +492,17 @@ namespace YooAsset.Editor
|
||||
textFiled1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
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();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -491,7 +512,7 @@ namespace YooAsset.Editor
|
||||
|
||||
try
|
||||
{
|
||||
collectAssetInfos = collector.GetAllCollectAssets(grouper);
|
||||
collectAssetInfos = collector.GetAllCollectAssets(group);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
@@ -509,8 +530,8 @@ namespace YooAsset.Editor
|
||||
string showInfo = collectAssetInfo.AssetPath;
|
||||
if (_enableAddressableToogle.value)
|
||||
{
|
||||
IAddressRule instance = AssetBundleGrouperSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, grouper.GrouperName);
|
||||
IAddressRule instance = AssetBundleCollectorSettingData.GetAddressRuleInstance(collector.AddressRuleName);
|
||||
AddressRuleData ruleData = new AddressRuleData(collectAssetInfo.AssetPath, collector.CollectPath, group.GroupName);
|
||||
string addressValue = instance.GetAssetAddress(ruleData);
|
||||
showInfo = $"[{addressValue}] {showInfo}";
|
||||
}
|
||||
@@ -527,21 +548,21 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void AddCollectorBtn_clicked()
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
|
||||
AssetBundleGrouperSettingData.CreateCollector(selectGrouper, string.Empty);
|
||||
AssetBundleCollectorSettingData.CreateCollector(selectGroup, string.Empty);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
|
||||
if (selectGroup == null)
|
||||
return;
|
||||
if (selectCollector == null)
|
||||
return;
|
||||
AssetBundleGrouperSettingData.RemoveCollector(selectGrouper, selectCollector);
|
||||
AssetBundleCollectorSettingData.RemoveCollector(selectGroup, selectCollector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
</uie:Toolbar>
|
||||
<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:ListView focusable="true" name="GrouperListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="GrouperAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<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="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
@@ -17,10 +17,10 @@
|
||||
<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: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:TextField picking-mode="Ignore" label="Grouper Name" name="GrouperName" />
|
||||
<ui:TextField picking-mode="Ignore" label="Grouper Desc" name="GrouperDesc" />
|
||||
<ui:TextField picking-mode="Ignore" label="Grouper Asset Tags" name="GrouperAssetTags" />
|
||||
<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="Group Name" name="GroupName" />
|
||||
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
|
||||
<ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" />
|
||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
@@ -16,12 +16,12 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 以组名+文件名为定位地址
|
||||
/// </summary>
|
||||
public class AddressByGrouperAndFileName : IAddressRule
|
||||
public class AddressByGroupAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
return $"{data.GrouperName}_{fileName}";
|
||||
return $"{data.GroupName}_{fileName}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ namespace YooAsset.Editor
|
||||
/// 以分组名称作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
public class PackGrouper : IPackRule
|
||||
public class PackGroup : IPackRule
|
||||
{
|
||||
string IPackRule.GetBundleName(PackRuleData data)
|
||||
{
|
||||
return data.GrouperName;
|
||||
return data.GroupName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public string AssetPath;
|
||||
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;
|
||||
CollectPath = collectPath;
|
||||
GrouperName = grouperName;
|
||||
GroupName = groupName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,19 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GrouperName;
|
||||
public string GroupName;
|
||||
|
||||
public PackRuleData(string assetPath)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
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;
|
||||
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 EViewMode _viewMode;
|
||||
private string _searchKeyWord;
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private string _searchKeyWord;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
@@ -92,6 +93,10 @@ namespace YooAsset.Editor
|
||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||
_summaryViewer.AttachParent(root);
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
AssetBundleRecorder.UnloadAll();
|
||||
}
|
||||
|
||||
private void ImportBtn_onClick()
|
||||
{
|
||||
@@ -99,19 +104,20 @@ namespace YooAsset.Editor
|
||||
if (string.IsNullOrEmpty(selectFilePath))
|
||||
return;
|
||||
|
||||
string jsonData = FileUtility.ReadFile(selectFilePath);
|
||||
_reportFilePath = selectFilePath;
|
||||
string jsonData = FileUtility.ReadFile(_reportFilePath);
|
||||
_buildReport = BuildReport.Deserialize(jsonData);
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
_summaryViewer.FillViewData(_buildReport);
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
if(_buildReport != null)
|
||||
if (_buildReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction0(DropdownMenuAction action)
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = (bundleInfo.SizeBytes / 1024f).ToString("f1") + " KB";
|
||||
label2.text = EditorUtility.FormatBytes(bundleInfo.SizeBytes);
|
||||
|
||||
// Hash
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace YooAsset.Editor
|
||||
private ListView _includeListView;
|
||||
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private string _searchKeyWord;
|
||||
private ESortMode _sortMode = ESortMode.BundleName;
|
||||
private bool _descendingSort = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
@@ -93,9 +93,10 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport, string searchKeyWord)
|
||||
public void FillViewData( BuildReport buildReport, string reprotFilePath, string searchKeyWord)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_reportFilePath = reprotFilePath;
|
||||
_searchKeyWord = searchKeyWord;
|
||||
RefreshView();
|
||||
}
|
||||
@@ -139,7 +140,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleTags)
|
||||
{
|
||||
if(_descendingSort)
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.GetTagsString()).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.GetTagsString()).ToList();
|
||||
@@ -171,7 +172,7 @@ namespace YooAsset.Editor
|
||||
else
|
||||
_topBar2.text = "Size ↑";
|
||||
}
|
||||
else if(_sortMode == ESortMode.BundleTags)
|
||||
else if (_sortMode == ESortMode.BundleTags)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar4.text = "Tags ↓";
|
||||
@@ -260,7 +261,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = (bundleInfo.SizeBytes / 1024f).ToString("f1") + " KB";
|
||||
label2.text = EditorUtility.FormatBytes(bundleInfo.SizeBytes);
|
||||
|
||||
// Hash
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
@@ -276,8 +277,22 @@ namespace YooAsset.Editor
|
||||
{
|
||||
ReportBundleInfo bundleInfo = item as ReportBundleInfo;
|
||||
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()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleName)
|
||||
|
||||
@@ -4,10 +4,12 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class EditorDefine
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
/// <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>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
@@ -15,7 +15,57 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public static class EditorTools
|
||||
{
|
||||
static EditorTools()
|
||||
{
|
||||
InitAssembly();
|
||||
}
|
||||
|
||||
#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>
|
||||
@@ -190,7 +240,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 控制台
|
||||
#region EditorConsole
|
||||
private static MethodInfo _clearConsoleMethod;
|
||||
private static MethodInfo ClearConsoleMethod
|
||||
{
|
||||
@@ -551,40 +601,6 @@ namespace YooAsset.Editor
|
||||
}
|
||||
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>
|
||||
/// 截取字符串
|
||||
@@ -594,7 +610,7 @@ namespace YooAsset.Editor
|
||||
/// <param name="key">关键字</param>
|
||||
/// <param name="includeKey">分割的结果里是否包含关键字</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))
|
||||
return content;
|
||||
@@ -614,6 +630,7 @@ namespace YooAsset.Editor
|
||||
else
|
||||
return content.Substring(startIndex + key.Length);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace YooAsset.Editor
|
||||
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();
|
||||
foreach (var assetPath in collectAssets)
|
||||
{
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace YooAsset
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载场景
|
||||
/// 加载场景
|
||||
/// </summary>
|
||||
public static SceneOperationHandle LoadSceneAsync(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
|
||||
{
|
||||
@@ -161,7 +161,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源对象
|
||||
/// 加载资源对象
|
||||
/// </summary>
|
||||
public static AssetOperationHandle LoadAssetAsync(string assetPath, System.Type assetType)
|
||||
{
|
||||
@@ -179,7 +179,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载所有子资源对象
|
||||
/// 加载子资源对象
|
||||
/// </summary>
|
||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(string assetPath, System.Type assetType)
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DependAssetBundleGrouper
|
||||
internal class DependAssetBundleGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// 依赖的资源包加载器列表
|
||||
@@ -12,7 +12,7 @@ namespace YooAsset
|
||||
private readonly List<AssetBundleLoaderBase> _dependBundles;
|
||||
|
||||
|
||||
public DependAssetBundleGrouper(string assetPath)
|
||||
public DependAssetBundleGroup(string assetPath)
|
||||
{
|
||||
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
||||
}
|
||||
|
||||
@@ -195,6 +195,7 @@ namespace YooAsset
|
||||
// 3. 检测APK拷贝文件结果
|
||||
if (_steps == ESteps.CheckDownloadFromApk)
|
||||
{
|
||||
Progress = _fileRequester.Progress();
|
||||
if (_fileRequester.IsDone() == false)
|
||||
return;
|
||||
|
||||
@@ -336,6 +337,7 @@ namespace YooAsset
|
||||
// 3. 检测服务器下载结果
|
||||
if (_steps == ESteps.CheckDownloadFromWeb)
|
||||
{
|
||||
Progress = _downloader.DownloadProgress;
|
||||
if (_downloader.IsDone() == false)
|
||||
return;
|
||||
|
||||
@@ -363,6 +365,7 @@ namespace YooAsset
|
||||
// 5. 检测APK拷贝文件结果
|
||||
if (_steps == ESteps.CheckDownloadFromApk)
|
||||
{
|
||||
Progress = _fileRequester.Progress();
|
||||
if (_fileRequester.IsDone() == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -26,19 +26,6 @@ namespace YooAsset
|
||||
private Scene _scene;
|
||||
private AsyncOperation _asyncOp;
|
||||
|
||||
/// <summary>
|
||||
/// 场景卸载进度
|
||||
/// </summary>
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_asyncOp == null)
|
||||
return 0;
|
||||
return _asyncOp.progress;
|
||||
}
|
||||
}
|
||||
|
||||
internal UnloadSceneOperation(string error)
|
||||
{
|
||||
_flag = EFlag.Error;
|
||||
@@ -87,6 +74,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Progress = _asyncOp.progress;
|
||||
if (_asyncOp.isDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace YooAsset
|
||||
internal abstract class BundledProvider : ProviderBase
|
||||
{
|
||||
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)
|
||||
{
|
||||
OwnerBundle = AssetSystem.CreateOwnerAssetBundleLoader(assetPath);
|
||||
OwnerBundle.Reference();
|
||||
OwnerBundle.AddProvider(this);
|
||||
DependBundles = new DependAssetBundleGrouper(assetPath);
|
||||
DependBundles = new DependAssetBundleGroup(assetPath);
|
||||
DependBundles.Reference();
|
||||
}
|
||||
public override void Destroy()
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset
|
||||
get
|
||||
{
|
||||
if (IsDone)
|
||||
return 100f;
|
||||
return 1f;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -39,10 +39,8 @@ namespace YooAsset
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = EStatus.Loading;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -52,7 +50,10 @@ namespace YooAsset
|
||||
// 1. 加载资源对象
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace YooAsset
|
||||
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
||||
if (Status == EStatus.Fail)
|
||||
{
|
||||
LastError = $"The load scene is invalid : {AssetPath}";
|
||||
LastError = $"The loaded scene is invalid : {AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
InvokeCompletion();
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset
|
||||
get
|
||||
{
|
||||
if (IsDone)
|
||||
return 100f;
|
||||
return 1f;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -39,10 +39,8 @@ namespace YooAsset
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = EStatus.Loading;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -62,7 +60,7 @@ namespace YooAsset
|
||||
List<UnityEngine.Object> result = new List<Object>(findAssets.Length);
|
||||
foreach (var findAsset in findAssets)
|
||||
{
|
||||
if (findAsset.GetType() == AssetType)
|
||||
if (AssetType.IsAssignableFrom(findAsset.GetType()))
|
||||
result.Add(findAsset);
|
||||
}
|
||||
AllAssetObjects = result.ToArray();
|
||||
|
||||
@@ -162,28 +162,6 @@ namespace YooAsset
|
||||
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>
|
||||
@@ -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 异步编程相关
|
||||
private TaskCompletionSource<object> _taskCompletionSource;
|
||||
protected void InvokeCompletion()
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace YooAsset
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度(0-100f)
|
||||
/// 下载进度
|
||||
/// </summary>
|
||||
public float DownloadProgress
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace YooAsset
|
||||
// 检测下载结果
|
||||
if (_steps == ESteps.CheckDownload)
|
||||
{
|
||||
_downloadProgress = _webRequest.downloadProgress * 100f;
|
||||
_downloadProgress = _webRequest.downloadProgress;
|
||||
_downloadedBytes = _webRequest.downloadedBytes;
|
||||
if (_operationHandle.isDone == false)
|
||||
{
|
||||
|
||||
@@ -203,7 +203,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.CheckDownload)
|
||||
{
|
||||
_downloadProgress = _threadDownloader.DownloadProgress * 100f;
|
||||
_downloadProgress = _threadDownloader.DownloadProgress;
|
||||
_downloadedBytes = _threadDownloader.DownloadedBytes;
|
||||
if (_threadDownloader.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -83,6 +83,16 @@ namespace YooAsset
|
||||
return _operationHandle.isDone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度
|
||||
/// </summary>
|
||||
public float Progress()
|
||||
{
|
||||
if (_operationHandle == null)
|
||||
return 0;
|
||||
return _operationHandle.progress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载是否发生错误
|
||||
/// </summary>
|
||||
|
||||
@@ -60,6 +60,16 @@ namespace YooAsset
|
||||
return _operationHandle.isDone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度
|
||||
/// </summary>
|
||||
public float Progress()
|
||||
{
|
||||
if (_operationHandle == null)
|
||||
return 0;
|
||||
return _operationHandle.progress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载是否发生错误
|
||||
/// </summary>
|
||||
|
||||
@@ -18,7 +18,12 @@ namespace YooAsset
|
||||
/// <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>
|
||||
/// 是否已经完成
|
||||
@@ -70,8 +75,8 @@ namespace YooAsset
|
||||
internal abstract void Update();
|
||||
internal void Finish()
|
||||
{
|
||||
Progress = 1f;
|
||||
_callback?.Invoke(this);
|
||||
|
||||
if (_taskCompletionSource != 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 Stopwatch _watch;
|
||||
private static Stopwatch _watch;
|
||||
private static long _maxTimeSlice;
|
||||
private static long _frameTime;
|
||||
|
||||
@@ -35,11 +35,12 @@ namespace YooAsset
|
||||
if (_watch.ElapsedMilliseconds - _frameTime >= _maxTimeSlice)
|
||||
return;
|
||||
|
||||
_operations[i].Update();
|
||||
if (_operations[i].IsDone)
|
||||
var operation = _operations[i];
|
||||
operation.Update();
|
||||
if (operation.IsDone)
|
||||
{
|
||||
_operations[i].Finish();
|
||||
_operations.RemoveAt(i);
|
||||
operation.Finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 编辑器资源路径
|
||||
/// </summary>
|
||||
public string EditorAssetPath { private set; get; }
|
||||
internal string EditorAssetPath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
|
||||
@@ -145,6 +145,7 @@ namespace YooAsset
|
||||
{
|
||||
_lastDownloadBytes = downloadBytes;
|
||||
_lastDownloadCount = CurrentDownloadCount;
|
||||
Progress = (float)_lastDownloadBytes / TotalDownloadBytes;
|
||||
OnDownloadProgressCallback?.Invoke(TotalDownloadCount, _lastDownloadCount, TotalDownloadBytes, _lastDownloadBytes);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,51 +13,63 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟运行的初始化操作
|
||||
/// 编辑器下模拟模式的初始化操作
|
||||
/// </summary>
|
||||
internal sealed class EditorPlayModeInitializationOperation : InitializationOperation
|
||||
internal sealed class EditorSimulateModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
Builder,
|
||||
Load,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorPlayModeImpl _impl;
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private string _simulatePatchManifestPath;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorPlayModeInitializationOperation(EditorPlayModeImpl impl)
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulatePatchManifestPath)
|
||||
{
|
||||
_impl = impl;
|
||||
_simulatePatchManifestPath = simulatePatchManifestPath;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.Builder;
|
||||
if (string.IsNullOrEmpty(_simulatePatchManifestPath))
|
||||
_steps = ESteps.Builder;
|
||||
else
|
||||
_steps = ESteps.Load;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.Builder)
|
||||
{
|
||||
string manifestFilePath = EditorPlayModeHelper.DryRunBuild();
|
||||
if (string.IsNullOrEmpty(manifestFilePath))
|
||||
_simulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild();
|
||||
if (string.IsNullOrEmpty(_simulatePatchManifestPath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
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;
|
||||
}
|
||||
if (File.Exists(manifestFilePath) == false)
|
||||
_steps = ESteps.Load;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.Load)
|
||||
{
|
||||
if (File.Exists(_simulatePatchManifestPath) == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Manifest file not found : {manifestFilePath}";
|
||||
Error = $"Manifest file not found : {_simulatePatchManifestPath}";
|
||||
return;
|
||||
}
|
||||
|
||||
YooLogger.Log($"Load manifest file in editor play mode : {manifestFilePath}");
|
||||
string jsonContent = FileUtility.ReadFile(manifestFilePath);
|
||||
_impl.AppPatchManifest = PatchManifest.Deserialize(jsonContent);
|
||||
YooLogger.Log($"Load manifest file : {_simulatePatchManifestPath}");
|
||||
string jsonContent = FileUtility.ReadFile(_simulatePatchManifestPath);
|
||||
var simulatePatchManifest = PatchManifest.Deserialize(jsonContent);
|
||||
_impl.SetSimulatePatchManifest(simulatePatchManifest);
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
@@ -65,7 +77,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线模式的初始化操作
|
||||
/// 离线运行模式的初始化操作
|
||||
/// </summary>
|
||||
internal sealed class OfflinePlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
@@ -96,6 +108,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.Update)
|
||||
{
|
||||
_appManifestLoader.Update();
|
||||
Progress = _appManifestLoader.Progress();
|
||||
if (_appManifestLoader.IsDone() == false)
|
||||
return;
|
||||
|
||||
@@ -104,20 +117,19 @@ namespace YooAsset
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _appManifestLoader.Error;
|
||||
throw new System.Exception($"FATAL : {_appManifestLoader.Error}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
_impl.AppPatchManifest = _appManifestLoader.Result;
|
||||
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 网络模式的初始化操作
|
||||
/// 网络运行模式的初始化操作
|
||||
/// </summary>
|
||||
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
@@ -170,6 +182,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.Update)
|
||||
{
|
||||
_appManifestLoader.Update();
|
||||
Progress = _appManifestLoader.Progress();
|
||||
if (_appManifestLoader.IsDone() == false)
|
||||
return;
|
||||
|
||||
@@ -178,14 +191,13 @@ namespace YooAsset
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _appManifestLoader.Error;
|
||||
throw new System.Exception($"FATAL : {_appManifestLoader.Error}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
_impl.AppPatchManifest = _appManifestLoader.Result;
|
||||
_impl.LocalPatchManifest = _appManifestLoader.Result;
|
||||
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
||||
_impl.SetLocalPatchManifest(_appManifestLoader.Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,6 +245,16 @@ namespace YooAsset
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载进度
|
||||
/// </summary>
|
||||
public float Progress()
|
||||
{
|
||||
if (_downloader2 == null)
|
||||
return 0;
|
||||
return _downloader2.Progress();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (IsDone())
|
||||
|
||||
@@ -172,6 +172,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.UpdateVerifyingCache)
|
||||
{
|
||||
Progress = GetVerifyProgress();
|
||||
if (UpdateVerifyingCache())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -201,7 +202,8 @@ namespace YooAsset
|
||||
{
|
||||
try
|
||||
{
|
||||
_impl.LocalPatchManifest = PatchManifest.Deserialize(content);
|
||||
var remotePatchManifest = PatchManifest.Deserialize(content);
|
||||
_impl.SetLocalPatchManifest(remotePatchManifest);
|
||||
|
||||
YooLogger.Log("Save remote patch manifest file.");
|
||||
string savePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
||||
@@ -223,7 +225,8 @@ namespace YooAsset
|
||||
YooLogger.Log("Load sandbox patch manifest file.");
|
||||
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
||||
string jsonData = File.ReadAllText(filePath);
|
||||
_impl.LocalPatchManifest = PatchManifest.Deserialize(jsonData);
|
||||
var sandboxPatchManifest = PatchManifest.Deserialize(jsonData);
|
||||
_impl.SetLocalPatchManifest(sandboxPatchManifest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -256,6 +259,7 @@ namespace YooAsset
|
||||
private readonly List<PatchBundle> _verifyingList = new List<PatchBundle>(100);
|
||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||
private int _verifyMaxNum = 32;
|
||||
private int _verifyTotalCount = 0;
|
||||
private int _verifySuccessCount = 0;
|
||||
private int _verifyFailCount = 0;
|
||||
|
||||
@@ -288,6 +292,7 @@ namespace YooAsset
|
||||
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
|
||||
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
||||
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
||||
_verifyTotalCount = _waitingList.Count;
|
||||
}
|
||||
private bool UpdateVerifyingCache()
|
||||
{
|
||||
@@ -356,6 +361,12 @@ namespace YooAsset
|
||||
}
|
||||
_verifyingList.Remove(info.Bundle);
|
||||
}
|
||||
private float GetVerifyProgress()
|
||||
{
|
||||
if (_verifyTotalCount == 0)
|
||||
return 1f;
|
||||
return (float)(_verifySuccessCount + _verifyFailCount) / _verifyTotalCount;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.CheckWebManifest)
|
||||
{
|
||||
Progress = _downloaderManifest.Progress();
|
||||
if (_downloaderManifest.IsDone() == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.CheckStaticVersion)
|
||||
{
|
||||
Progress = _downloader.Progress();
|
||||
if (_downloader.IsDone() == false)
|
||||
return;
|
||||
|
||||
@@ -105,7 +106,7 @@ namespace YooAsset
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"URL : {_downloader.URL} Error : static version content is invalid.";
|
||||
|
||||
@@ -56,6 +56,10 @@ namespace YooAsset
|
||||
[NonSerialized]
|
||||
public readonly Dictionary<string, string> AssetPathMapping = new Dictionary<string, string>();
|
||||
|
||||
// 资源路径映射相关
|
||||
private bool _isInitAssetPathMapping = false;
|
||||
private bool _locationToLower = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置资源标签列表
|
||||
@@ -141,18 +145,72 @@ namespace YooAsset
|
||||
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>
|
||||
public string MappingToAssetPath(string location)
|
||||
{
|
||||
if (_locationToLower)
|
||||
location = location.ToLower();
|
||||
|
||||
if (AssetPathMapping.TryGetValue(location, out string assetPath))
|
||||
{
|
||||
return assetPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Failed to mapping location to asset path : {location}");
|
||||
YooLogger.Error($"Failed to mapping location to asset path : {location}");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -192,42 +250,6 @@ namespace YooAsset
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
internal static class EditorPlayModeHelper
|
||||
internal static class EditorSimulateModeHelper
|
||||
{
|
||||
private static System.Type _classType;
|
||||
|
||||
public static string DryRunBuild()
|
||||
public static string SimulateBuild()
|
||||
{
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleRuntimeBuilder");
|
||||
InvokePublicStaticMethod(_classType, "FastBuild");
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleSimulateBuilder");
|
||||
InvokePublicStaticMethod(_classType, "SimulateBuild");
|
||||
return 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)
|
||||
{
|
||||
@@ -30,8 +30,8 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
#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
|
||||
@@ -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 PatchManifest AppPatchManifest;
|
||||
internal PatchManifest LocalPatchManifest;
|
||||
internal PatchManifest AppPatchManifest { private set; get; }
|
||||
internal PatchManifest LocalPatchManifest { private set; get; }
|
||||
|
||||
// 参数相关
|
||||
internal bool LocationToLower { private set; get; }
|
||||
internal bool ClearCacheWhenDirty { private set; get; }
|
||||
private string _defaultHostServer;
|
||||
private string _fallbackHostServer;
|
||||
@@ -19,8 +20,9 @@ namespace YooAsset
|
||||
/// <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;
|
||||
_defaultHostServer = defaultHostServer;
|
||||
_fallbackHostServer = fallbackHostServer;
|
||||
@@ -274,6 +276,17 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
// 设置资源清单
|
||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
AppPatchManifest = patchManifest;
|
||||
}
|
||||
internal void SetLocalPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
LocalPatchManifest = patchManifest;
|
||||
LocalPatchManifest.InitAssetPathMapping(LocationToLower);
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||
{
|
||||
@@ -309,9 +322,13 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string bundleName)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByBundleName(LocalPatchManifest, bundleName);
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByTag(LocalPatchManifest, tags);
|
||||
return PatchHelper.GetAssetsInfoByTags(LocalPatchManifest, tags);
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
|
||||
@@ -6,13 +6,15 @@ namespace YooAsset
|
||||
{
|
||||
internal class OfflinePlayModeImpl : IBundleServices
|
||||
{
|
||||
internal PatchManifest AppPatchManifest;
|
||||
private PatchManifest _appPatchManifest;
|
||||
private bool _locationToLower;
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync()
|
||||
public InitializationOperation InitializeAsync(bool locationToLower)
|
||||
{
|
||||
_locationToLower = locationToLower;
|
||||
var operation = new OfflinePlayModeInitializationOperation(this);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
return operation;
|
||||
@@ -23,9 +25,9 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public int GetResourceVersion()
|
||||
{
|
||||
if (AppPatchManifest == null)
|
||||
if (_appPatchManifest == null)
|
||||
return 0;
|
||||
return AppPatchManifest.ResourceVersion;
|
||||
return _appPatchManifest.ResourceVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -33,18 +35,25 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
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);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 设置资源清单
|
||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
_appPatchManifest = patchManifest;
|
||||
_appPatchManifest.InitAssetPathMapping(_locationToLower);
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
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);
|
||||
return bundleInfo;
|
||||
@@ -56,21 +65,25 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string bundleName)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByBundleName(_appPatchManifest, bundleName);
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return PatchHelper.GetAssetsInfoByTag(AppPatchManifest, tags);
|
||||
return PatchHelper.GetAssetsInfoByTags(_appPatchManifest, tags);
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return AppPatchManifest.MappingToAssetPath(location);
|
||||
return _appPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
return AppPatchManifest.GetBundleName(assetPath);
|
||||
return _appPatchManifest.GetBundleName(assetPath);
|
||||
}
|
||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||
{
|
||||
return AppPatchManifest.GetAllDependencies(assetPath);
|
||||
return _appPatchManifest.GetAllDependencies(assetPath);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
BundleInfo GetBundleInfo(string bundleName);
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
AssetInfo[] GetAssetInfos(string bundleName);
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace YooAsset
|
||||
/// <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);
|
||||
foreach (var patchAsset in patchManifest.AssetList)
|
||||
@@ -189,5 +189,20 @@ namespace YooAsset
|
||||
}
|
||||
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.Diagnostics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -13,17 +14,18 @@ namespace YooAsset
|
||||
public enum EPlayMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 编辑器下模拟运行模式
|
||||
/// 编辑器下的模拟模式
|
||||
/// 注意:在初始化的时候自动构建真机模拟环境。
|
||||
/// </summary>
|
||||
EditorPlayMode,
|
||||
EditorSimulateMode,
|
||||
|
||||
/// <summary>
|
||||
/// 离线模式
|
||||
/// 离线运行模式
|
||||
/// </summary>
|
||||
OfflinePlayMode,
|
||||
|
||||
/// <summary>
|
||||
/// 网络模式
|
||||
/// 网络运行模式
|
||||
/// </summary>
|
||||
HostPlayMode,
|
||||
}
|
||||
@@ -33,6 +35,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public abstract class CreateParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower = false;
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位服务接口
|
||||
/// </summary>
|
||||
@@ -55,21 +62,26 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟运行模式参数
|
||||
/// 编辑器下模拟运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class EditorPlayModeParameters : CreateParameters
|
||||
public class EditorSimulateModeParameters : CreateParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 用于模拟运行的资源清单路径
|
||||
/// 注意:如果路径为空,会自动重新构建补丁清单。
|
||||
/// </summary>
|
||||
public string SimulatePatchManifestPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线模式参数
|
||||
/// 离线运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class OfflinePlayModeParameters : CreateParameters
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 网络模式参数
|
||||
/// 网络运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class HostPlayModeParameters : CreateParameters
|
||||
{
|
||||
@@ -96,10 +108,12 @@ namespace YooAsset
|
||||
|
||||
|
||||
private static bool _isInitialize = false;
|
||||
private static string _initializeError = string.Empty;
|
||||
private static EOperationStatus _initializeStatus = EOperationStatus.None;
|
||||
private static EPlayMode _playMode;
|
||||
private static IBundleServices _bundleServices;
|
||||
private static ILocationServices _locationServices;
|
||||
private static EditorPlayModeImpl _editorPlayModeImpl;
|
||||
private static EditorSimulateModeImpl _editorSimulateModeImpl;
|
||||
private static OfflinePlayModeImpl _offlinePlayModeImpl;
|
||||
private static HostPlayModeImpl _hostPlayModeImpl;
|
||||
|
||||
@@ -118,8 +132,8 @@ namespace YooAsset
|
||||
_locationServices = parameters.LocationServices;
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
if (parameters is EditorPlayModeParameters)
|
||||
throw new Exception($"Editor play mode only support unity editor.");
|
||||
if (parameters is EditorSimulateModeParameters)
|
||||
throw new Exception($"Editor simulate mode only support unity editor.");
|
||||
#endif
|
||||
|
||||
// 创建驱动器
|
||||
@@ -141,15 +155,15 @@ namespace YooAsset
|
||||
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");
|
||||
}
|
||||
|
||||
// 运行模式
|
||||
if (parameters is EditorPlayModeParameters)
|
||||
_playMode = EPlayMode.EditorPlayMode;
|
||||
if (parameters is EditorSimulateModeParameters)
|
||||
_playMode = EPlayMode.EditorSimulateMode;
|
||||
else if (parameters is OfflinePlayModeParameters)
|
||||
_playMode = EPlayMode.OfflinePlayMode;
|
||||
else if (parameters is HostPlayModeParameters)
|
||||
@@ -172,19 +186,23 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 初始化资源系统
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
InitializationOperation initializeOperation;
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
_editorPlayModeImpl = new EditorPlayModeImpl();
|
||||
_bundleServices = _editorPlayModeImpl;
|
||||
_editorSimulateModeImpl = new EditorSimulateModeImpl();
|
||||
_bundleServices = _editorSimulateModeImpl;
|
||||
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)
|
||||
{
|
||||
_offlinePlayModeImpl = new OfflinePlayModeImpl();
|
||||
_bundleServices = _offlinePlayModeImpl;
|
||||
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||
return _offlinePlayModeImpl.InitializeAsync();
|
||||
initializeOperation = _offlinePlayModeImpl.InitializeAsync(parameters.LocationToLower);
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
@@ -192,7 +210,8 @@ namespace YooAsset
|
||||
_bundleServices = _hostPlayModeImpl;
|
||||
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
||||
return _hostPlayModeImpl.InitializeAsync(
|
||||
initializeOperation = _hostPlayModeImpl.InitializeAsync(
|
||||
hostPlayModeParameters.LocationToLower,
|
||||
hostPlayModeParameters.ClearCacheWhenDirty,
|
||||
hostPlayModeParameters.DefaultHostServer,
|
||||
hostPlayModeParameters.FallbackHostServer);
|
||||
@@ -201,6 +220,15 @@ namespace YooAsset
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
// 监听初始化结果
|
||||
initializeOperation.Completed += InitializeOperation_Completed;
|
||||
return initializeOperation;
|
||||
}
|
||||
private static void InitializeOperation_Completed(AsyncOperationBase op)
|
||||
{
|
||||
_initializeStatus = op.Status;
|
||||
_initializeError = op.Error;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -209,7 +237,8 @@ namespace YooAsset
|
||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
||||
{
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var operation = new EditorPlayModeUpdateStaticVersionOperation();
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
@@ -240,7 +269,8 @@ namespace YooAsset
|
||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||
public static UpdateManifestOperation UpdateManifestAsync(int resourceVersion, int timeout = 60)
|
||||
{
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var operation = new EditorPlayModeUpdateManifestOperation();
|
||||
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>
|
||||
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.");
|
||||
return _editorPlayModeImpl.GetResourceVersion();
|
||||
return _editorSimulateModeImpl.GetResourceVersion();
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
@@ -310,12 +350,25 @@ namespace YooAsset
|
||||
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>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static BundleInfo GetBundleInfo(string location)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||
return _bundleServices.GetBundleInfo(bundleName);
|
||||
@@ -327,31 +380,42 @@ namespace YooAsset
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static BundleInfo GetBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
string bundleName = _bundleServices.GetBundleName(assetInfo.AssetPath);
|
||||
return _bundleServices.GetBundleInfo(bundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
/// <param name="bundleInfo">资源包信息</param>
|
||||
public static AssetInfo[] GetAssetInfos(BundleInfo bundleInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _bundleServices.GetAssetInfos(bundleInfo.BundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <returns></returns>
|
||||
public static AssetInfo[] GetAssetInfos(string tag)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
string[] tags = new string[] { tag };
|
||||
return _bundleServices.GetAssetInfos(tags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取调试信息
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
internal static void GetDebugReport(DebugReport report)
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
public static AssetInfo[] GetAssetInfos(string[] tags)
|
||||
{
|
||||
if (report == null)
|
||||
YooLogger.Error($"{nameof(DebugReport)} is null");
|
||||
|
||||
AssetSystem.GetDebugReport(report);
|
||||
DebugCheckInitialize();
|
||||
return _bundleServices.GetAssetInfos(tags);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 场景加载
|
||||
/// <summary>
|
||||
@@ -363,6 +427,7 @@ namespace YooAsset
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
string scenePath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
||||
return handle;
|
||||
@@ -377,6 +442,7 @@ namespace YooAsset
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
string scenePath = assetInfo.AssetPath;
|
||||
var handle = AssetSystem.LoadSceneAsync(scenePath, sceneMode, activateOnLoad, priority);
|
||||
return handle;
|
||||
@@ -391,6 +457,7 @@ namespace YooAsset
|
||||
/// <param name="copyPath">拷贝路径</param>
|
||||
public static RawFileOperation GetRawFileAsync(string location, string copyPath = null)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(location);
|
||||
return GetRawFileInternal(assetPath, copyPath);
|
||||
}
|
||||
@@ -402,144 +469,17 @@ namespace YooAsset
|
||||
/// <param name="copyPath">拷贝路径</param>
|
||||
public static RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
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)
|
||||
{
|
||||
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(bundleName);
|
||||
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
@@ -562,6 +502,79 @@ namespace YooAsset
|
||||
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)
|
||||
{
|
||||
var handle = AssetSystem.LoadAssetAsync(assetPath, assetType);
|
||||
@@ -569,6 +582,79 @@ namespace YooAsset
|
||||
handle.WaitForAsyncComplete();
|
||||
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)
|
||||
{
|
||||
var handle = AssetSystem.LoadSubAssetsAsync(assetPath, assetType);
|
||||
@@ -587,6 +673,7 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
@@ -598,7 +685,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
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>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -623,7 +711,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
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>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -650,7 +739,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
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>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -683,7 +773,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
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>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -717,6 +808,7 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public static PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return CreatePatchUnpacker(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
@@ -728,7 +820,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
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>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||
@@ -761,7 +854,8 @@ namespace YooAsset
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public static UpdatePackageOperation UpdatePackageAsync(int resourceVersion, int timeout = 60)
|
||||
{
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var operation = new EditorPlayModeUpdatePackageOperation();
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
@@ -833,21 +927,33 @@ namespace YooAsset
|
||||
// 轮询更新资源系统
|
||||
AssetSystem.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址转换为资源完整路径
|
||||
/// </summary>
|
||||
internal static string MappingToAssetPath(string location)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
CheckLocation(location);
|
||||
#endif
|
||||
|
||||
DebugCheckLocation(location);
|
||||
return _bundleServices.MappingToAssetPath(location);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private static void CheckLocation(string location)
|
||||
#region 调试方法
|
||||
[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))
|
||||
{
|
||||
UnityEngine.Debug.LogError("location param is null or empty!");
|
||||
YooLogger.Error("location param is null or empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -856,14 +962,13 @@ namespace YooAsset
|
||||
if (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)
|
||||
UnityEngine.Debug.LogWarning($"Found illegal character in location : \"{location}\"");
|
||||
YooLogger.Warning($"Found illegal character in location : \"{location}\"");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.tuyoogame.yooasset",
|
||||
"displayName": "YooAsset",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"unity": "2019.4",
|
||||
"description": "unity3d resources management system",
|
||||
"author": {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
- **Build Mode**
|
||||
|
||||
构建模式:强制构建模式,增量构建模式,快速构建模式,演练构建模式。
|
||||
构建模式:强制构建模式,增量构建模式,演练构建模式,模拟构建模式。
|
||||
|
||||
- **Encryption**
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ YooAssets.InitializeAsync(CreateParameters parameters);
|
||||
````c#
|
||||
private IEnumerator InitializeYooAsset()
|
||||
{
|
||||
var createParameters = new YooAssets.EditorPlayModeParameters();
|
||||
var createParameters = new YooAssets.EditorSimulateModeParameters();
|
||||
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||
yield return YooAssets.InitializeAsync(createParameters);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user