Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b238759f61 | ||
|
|
2bb0d18891 | ||
|
|
7d5b6504f4 | ||
|
|
63f90e1537 | ||
|
|
65b43feb38 | ||
|
|
4f00a19344 | ||
|
|
3bfca7d340 | ||
|
|
8538d0de28 | ||
|
|
5425e17d6f | ||
|
|
bb3065d08d | ||
|
|
1adc3d7ed6 | ||
|
|
556b23b488 | ||
|
|
5b0c189d75 | ||
|
|
161fdff09a | ||
|
|
81b3dd57b1 | ||
|
|
1ab0f447d2 | ||
|
|
9ac07e94d1 | ||
|
|
fee6e8f4dd | ||
|
|
1e39b1af6d | ||
|
|
727d841d47 | ||
|
|
5e0d4d6ee1 | ||
|
|
32ce99949b | ||
|
|
fbb9bff3c7 | ||
|
|
6471b237ce | ||
|
|
d452c610c1 | ||
|
|
009fa88402 | ||
|
|
6d26276352 |
@@ -71,7 +71,7 @@ namespace Cysharp.Threading.Tasks
|
|||||||
result.completed = false;
|
result.completed = false;
|
||||||
TaskTracker.TrackActiveTask(result, 3);
|
TaskTracker.TrackActiveTask(result, 3);
|
||||||
|
|
||||||
if(progress is not null)
|
if(progress != null)
|
||||||
{
|
{
|
||||||
PlayerLoopHelper.AddAction(timing, result);
|
PlayerLoopHelper.AddAction(timing, result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
|
#if UNITY_2020_1_OR_NEWER && ! UNITY_2021
|
||||||
|
#define UNITY_2020_BUG
|
||||||
|
#endif
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using YooAsset;
|
using YooAsset;
|
||||||
using static Cysharp.Threading.Tasks.Internal.Error;
|
using static Cysharp.Threading.Tasks.Internal.Error;
|
||||||
|
|
||||||
|
|
||||||
namespace Cysharp.Threading.Tasks
|
namespace Cysharp.Threading.Tasks
|
||||||
{
|
{
|
||||||
public static class OperationHandleBaseExtensions
|
public static class OperationHandleBaseExtensions
|
||||||
@@ -71,11 +77,29 @@ namespace Cysharp.Threading.Tasks
|
|||||||
result.completed = false;
|
result.completed = false;
|
||||||
TaskTracker.TrackActiveTask(result, 3);
|
TaskTracker.TrackActiveTask(result, 3);
|
||||||
|
|
||||||
if(progress is not null)
|
if(progress != null)
|
||||||
{
|
{
|
||||||
PlayerLoopHelper.AddAction(timing, result);
|
PlayerLoopHelper.AddAction(timing, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BUG 在 Unity 2020.3.36 版本测试中, IL2Cpp 会报 如下错误
|
||||||
|
// BUG ArgumentException: Incompatible Delegate Types. First is System.Action`1[[YooAsset.AssetOperationHandle, YooAsset, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] second is System.Action`1[[YooAsset.OperationHandleBase, YooAsset, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]
|
||||||
|
// BUG 也可能报的是 Action '1' Action '1' 的 InvalidCastException
|
||||||
|
// BUG 此处不得不这么修改, 如果后续 Unity 修复了这个问题, 可以恢复之前的写法
|
||||||
|
#if UNITY_2020_BUG
|
||||||
|
switch(handle)
|
||||||
|
{
|
||||||
|
case AssetOperationHandle asset_handle:
|
||||||
|
asset_handle.Completed += result.AssetContinuation;
|
||||||
|
break;
|
||||||
|
case SceneOperationHandle scene_handle:
|
||||||
|
scene_handle.Completed += result.SceneContinuation;
|
||||||
|
break;
|
||||||
|
case SubAssetsOperationHandle sub_asset_handle:
|
||||||
|
sub_asset_handle.Completed += result.SubContinuation;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
switch(handle)
|
switch(handle)
|
||||||
{
|
{
|
||||||
case AssetOperationHandle asset_handle:
|
case AssetOperationHandle asset_handle:
|
||||||
@@ -88,11 +112,50 @@ namespace Cysharp.Threading.Tasks
|
|||||||
sub_asset_handle.Completed += result.continuationAction;
|
sub_asset_handle.Completed += result.continuationAction;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
token = result.core.Version;
|
token = result.core.Version;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#if UNITY_2020_BUG
|
||||||
|
private void AssetContinuation(AssetOperationHandle handle)
|
||||||
|
{
|
||||||
|
handle.Completed -= AssetContinuation;
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SceneContinuation(SceneOperationHandle handle)
|
||||||
|
{
|
||||||
|
handle.Completed -= SceneContinuation;
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SubContinuation(SubAssetsOperationHandle handle)
|
||||||
|
{
|
||||||
|
handle.Completed -= SubContinuation;
|
||||||
|
BaseContinuation();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
private void BaseContinuation()
|
||||||
|
{
|
||||||
|
if(completed)
|
||||||
|
{
|
||||||
|
TryReturn();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
completed = true;
|
||||||
|
if(handle.Status == EOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
core.TrySetException(new Exception(handle.LastError));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
core.TrySetResult(AsyncUnit.Default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Continuation(OperationHandleBase _)
|
private void Continuation(OperationHandleBase _)
|
||||||
{
|
{
|
||||||
@@ -109,22 +172,7 @@ namespace Cysharp.Threading.Tasks
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(completed)
|
BaseContinuation();
|
||||||
{
|
|
||||||
TryReturn();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
completed = true;
|
|
||||||
if(handle.Status == EOperationStatus.Failed)
|
|
||||||
{
|
|
||||||
core.TrySetException(new Exception(handle.LastError));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
core.TrySetResult(AsyncUnit.Default);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TryReturn()
|
bool TryReturn()
|
||||||
|
|||||||
@@ -2,6 +2,56 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.1.1] - 2022-07-07
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了AssetBundleDebugger窗口,View下拉页签切换无效的问题。
|
||||||
|
- 修复了在Unity2020.3版本下UniTask在真机上的一个IL2CPP相关的错误。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 优化了AssetBundleDebugger窗口,增加了帧数显示以及回放功能。
|
||||||
|
- 优化了AssetBundleBuilder的代码结构。
|
||||||
|
- 增强了YooAssets.GetRawFileAsync()方法的容错。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了OperationHandleBase.GetAssetInfo()方法。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源信息
|
||||||
|
/// </summary>
|
||||||
|
public AssetInfo GetAssetInfo();
|
||||||
|
````
|
||||||
|
|
||||||
|
- 新增了AssetOperationHandle.GetAssetObjet<TAsset>()方法。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TAsset">资源类型</typeparam>
|
||||||
|
public TAsset GetAssetObjet<TAsset>();
|
||||||
|
````
|
||||||
|
|
||||||
|
- 新增了弱联网情况下加载补丁清单方法。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
/// <summary>
|
||||||
|
/// 弱联网情况下加载补丁清单
|
||||||
|
/// 注意:当指定版本内容验证失败后会返回失败。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="resourceVersion">指定的资源版本</param>
|
||||||
|
public static UpdateManifestOperation WeaklyUpdateManifestAsync(int resourceVersion);
|
||||||
|
````
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- 离线运行模式(OfflinePlayMode)下移除了资内置资源解压相关逻辑。
|
||||||
|
- 移除了初始化参数:AutoReleaseGameObjectHandle及相关代码逻辑。
|
||||||
|
|
||||||
## [1.1.0] - 2022-06-23
|
## [1.1.0] - 2022-06-23
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -8,96 +8,6 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class AssetBundleBuilder
|
public class AssetBundleBuilder
|
||||||
{
|
{
|
||||||
public class BuildParametersContext : IContextObject
|
|
||||||
{
|
|
||||||
private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 构建参数
|
|
||||||
/// </summary>
|
|
||||||
public BuildParameters Parameters { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 构建管线的输出目录
|
|
||||||
/// </summary>
|
|
||||||
public string PipelineOutputDirectory { private set; get; }
|
|
||||||
|
|
||||||
|
|
||||||
public BuildParametersContext(BuildParameters parameters)
|
|
||||||
{
|
|
||||||
Parameters = parameters;
|
|
||||||
|
|
||||||
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
|
||||||
if (parameters.BuildMode == EBuildMode.DryRunBuild)
|
|
||||||
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
|
|
||||||
else if (parameters.BuildMode == EBuildMode.SimulateBuild)
|
|
||||||
PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取本次构建的补丁目录
|
|
||||||
/// </summary>
|
|
||||||
public string GetPackageDirectory()
|
|
||||||
{
|
|
||||||
return $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.BuildVersion}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取构建选项
|
|
||||||
/// </summary>
|
|
||||||
public BuildAssetBundleOptions GetPipelineBuildOptions()
|
|
||||||
{
|
|
||||||
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
|
||||||
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
|
||||||
|
|
||||||
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.SimulateBuild)
|
|
||||||
throw new Exception("Should never get here !");
|
|
||||||
|
|
||||||
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
|
||||||
{
|
|
||||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
|
||||||
return opt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Parameters.CompressOption == ECompressOption.Uncompressed)
|
|
||||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
|
||||||
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
|
||||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
|
||||||
|
|
||||||
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
|
|
||||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
|
||||||
if (Parameters.DisableWriteTypeTree)
|
|
||||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
|
||||||
if (Parameters.IgnoreTypeTreeChanges)
|
|
||||||
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
|
||||||
|
|
||||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
|
||||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
|
||||||
|
|
||||||
return opt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取构建的耗时(单位:秒)
|
|
||||||
/// </summary>
|
|
||||||
public float GetBuildingSeconds()
|
|
||||||
{
|
|
||||||
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
|
||||||
return seconds;
|
|
||||||
}
|
|
||||||
public void BeginWatch()
|
|
||||||
{
|
|
||||||
_buildWatch.Start();
|
|
||||||
}
|
|
||||||
public void StopWatch()
|
|
||||||
{
|
|
||||||
_buildWatch.Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly BuildContext _buildContext = new BuildContext();
|
private readonly BuildContext _buildContext = new BuildContext();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class BuildParametersContext : IContextObject
|
||||||
|
{
|
||||||
|
private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建参数
|
||||||
|
/// </summary>
|
||||||
|
public BuildParameters Parameters { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建管线的输出目录
|
||||||
|
/// </summary>
|
||||||
|
public string PipelineOutputDirectory { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
public BuildParametersContext(BuildParameters parameters)
|
||||||
|
{
|
||||||
|
Parameters = parameters;
|
||||||
|
|
||||||
|
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
|
||||||
|
if (parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
|
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
|
||||||
|
else if (parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
|
PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取本次构建的补丁目录
|
||||||
|
/// </summary>
|
||||||
|
public string GetPackageDirectory()
|
||||||
|
{
|
||||||
|
return $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.BuildVersion}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取构建选项
|
||||||
|
/// </summary>
|
||||||
|
public BuildAssetBundleOptions GetPipelineBuildOptions()
|
||||||
|
{
|
||||||
|
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
||||||
|
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
||||||
|
|
||||||
|
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.SimulateBuild)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
|
{
|
||||||
|
opt |= BuildAssetBundleOptions.DryRunBuild;
|
||||||
|
return opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Parameters.CompressOption == ECompressOption.Uncompressed)
|
||||||
|
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||||
|
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
||||||
|
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||||
|
|
||||||
|
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
|
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||||
|
if (Parameters.DisableWriteTypeTree)
|
||||||
|
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||||
|
if (Parameters.IgnoreTypeTreeChanges)
|
||||||
|
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
||||||
|
|
||||||
|
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
||||||
|
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
||||||
|
|
||||||
|
return opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取构建的耗时(单位:秒)
|
||||||
|
/// </summary>
|
||||||
|
public float GetBuildingSeconds()
|
||||||
|
{
|
||||||
|
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
||||||
|
return seconds;
|
||||||
|
}
|
||||||
|
public void BeginWatch()
|
||||||
|
{
|
||||||
|
_buildWatch.Start();
|
||||||
|
}
|
||||||
|
public void StopWatch()
|
||||||
|
{
|
||||||
|
_buildWatch.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b84510feab7cbe44a9b6d8ef0b3f559c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -18,7 +18,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
// 模拟构建模式下跳过引擎构建
|
// 模拟构建模式下跳过引擎构建
|
||||||
@@ -46,7 +46,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝原生文件
|
/// 拷贝原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyRawBundle(BuildMapContext buildMapContext, AssetBundleBuilder.BuildParametersContext buildParametersContext)
|
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
// 注意:我们只有在强制重建的时候才会拷贝
|
// 注意:我们只有在强制重建的时候才会拷贝
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
if (buildParameters.Parameters.CopyBuildinTagFiles)
|
if (buildParameters.Parameters.CopyBuildinTagFiles)
|
||||||
{
|
{
|
||||||
// 清空流目录
|
// 清空流目录
|
||||||
|
|||||||
@@ -10,17 +10,17 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
|
||||||
CreatePatchManifestFile(buildParameters, buildMapContext, encryptionContext);
|
CreatePatchManifestFile(buildParameters, buildMapContext, encryptionContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁清单文件到输出目录
|
/// 创建补丁清单文件到输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePatchManifestFile(AssetBundleBuilder.BuildParametersContext buildParameters,
|
private void CreatePatchManifestFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext,
|
||||||
BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext)
|
TaskEncryption.EncryptionContext encryptionContext)
|
||||||
{
|
{
|
||||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包列表
|
/// 获取资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PatchBundle> GetAllPatchBundle(AssetBundleBuilder.BuildParametersContext buildParameters,
|
private List<PatchBundle> GetAllPatchBundle(BuildParametersContext buildParameters, BuildMapContext buildMapContext,
|
||||||
BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext)
|
TaskEncryption.EncryptionContext encryptionContext)
|
||||||
{
|
{
|
||||||
List<PatchBundle> result = new List<PatchBundle>(1000);
|
List<PatchBundle> result = new List<PatchBundle>(1000);
|
||||||
|
|
||||||
@@ -124,8 +124,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源列表
|
/// 获取资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PatchAsset> GetAllPatchAsset(AssetBundleBuilder.BuildParametersContext buildParameters,
|
private List<PatchAsset> GetAllPatchAsset(BuildParametersContext buildParameters, BuildMapContext buildMapContext, PatchManifest patchManifest)
|
||||||
BuildMapContext buildMapContext, PatchManifest patchManifest)
|
|
||||||
{
|
{
|
||||||
List<PatchAsset> result = new List<PatchAsset>(1000);
|
List<PatchAsset> result = new List<PatchAsset>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
@@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPatchFiles(AssetBundleBuilder.BuildParametersContext buildParameters)
|
private void CopyPatchFiles(BuildParametersContext buildParameters)
|
||||||
{
|
{
|
||||||
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||||
string packageDirectory = buildParameters.GetPackageDirectory();
|
string packageDirectory = buildParameters.GetPackageDirectory();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
buildParameters.StopWatch();
|
buildParameters.StopWatch();
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
private void CreateReportFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||||
BuildReport buildReport = new BuildReport();
|
BuildReport buildReport = new BuildReport();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
@@ -45,7 +45,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密文件
|
/// 加密文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> EncryptFiles(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
private List<string> EncryptFiles(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
var encryptionServices = buildParameters.Parameters.EncryptionServices;
|
var encryptionServices = buildParameters.Parameters.EncryptionServices;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode);
|
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
BuildRunner.Log("构建内容准备完毕!");
|
BuildRunner.Log("构建内容准备完毕!");
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
buildParameters.BeginWatch();
|
buildParameters.BeginWatch();
|
||||||
|
|
||||||
// 检测构建平台是否合法
|
// 检测构建平台是否合法
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
|
||||||
// 模拟构建模式下跳过验证
|
// 模拟构建模式下跳过验证
|
||||||
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
|
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
@@ -32,7 +32,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
||||||
|
|
||||||
|
|||||||
@@ -45,12 +45,15 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private Label _playerName;
|
private Label _playerName;
|
||||||
private ToolbarMenu _viewModeMenu;
|
private ToolbarMenu _viewModeMenu;
|
||||||
|
private SliderInt _frameSlider;
|
||||||
private DebuggerAssetListViewer _assetListViewer;
|
private DebuggerAssetListViewer _assetListViewer;
|
||||||
private DebuggerBundleListViewer _bundleListViewer;
|
private DebuggerBundleListViewer _bundleListViewer;
|
||||||
|
|
||||||
private EViewMode _viewMode;
|
private EViewMode _viewMode;
|
||||||
private DebugReport _debugReport;
|
|
||||||
private string _searchKeyWord;
|
private string _searchKeyWord;
|
||||||
|
private DebugReport _currentReport;
|
||||||
|
private RemotePlayerSession _currentPlayerSession;
|
||||||
|
private int _rangeIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
@@ -76,14 +79,36 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 视口模式菜单
|
// 视口模式菜单
|
||||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction, ViewModeMenuFun, EViewMode.AssetView);
|
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction, ViewModeMenuFun, EViewMode.BundleView);
|
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
|
||||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||||
|
|
||||||
// 搜索栏
|
// 搜索栏
|
||||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||||
|
|
||||||
|
// 帧数相关
|
||||||
|
{
|
||||||
|
_frameSlider = root.Q<SliderInt>("FrameSlider");
|
||||||
|
_frameSlider.label = "Frame:";
|
||||||
|
_frameSlider.highValue = 0;
|
||||||
|
_frameSlider.lowValue = 0;
|
||||||
|
_frameSlider.value = 0;
|
||||||
|
_frameSlider.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
OnFrameSliderChange(evt.newValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
var frameLast = root.Q<ToolbarButton>("FrameLast");
|
||||||
|
frameLast.clicked += OnFrameLast_clicked;
|
||||||
|
|
||||||
|
var frameNext = root.Q<ToolbarButton>("FrameNext");
|
||||||
|
frameNext.clicked += OnFrameNext_clicked;
|
||||||
|
|
||||||
|
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
||||||
|
frameClear.clicked += OnFrameClear_clicked;
|
||||||
|
}
|
||||||
|
|
||||||
// 加载视图
|
// 加载视图
|
||||||
_assetListViewer = new DebuggerAssetListViewer();
|
_assetListViewer = new DebuggerAssetListViewer();
|
||||||
_assetListViewer.InitViewer();
|
_assetListViewer.InitViewer();
|
||||||
@@ -126,7 +151,6 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
Debug.Log($"Game player disconnection : {playerId}");
|
Debug.Log($"Game player disconnection : {playerId}");
|
||||||
_playerName.text = $"Disconneced player : {playerId}";
|
_playerName.text = $"Disconneced player : {playerId}";
|
||||||
RemovePlayerSession(playerId);
|
|
||||||
}
|
}
|
||||||
private void OnHandlePlayerMessage(MessageEventArgs args)
|
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||||
{
|
{
|
||||||
@@ -135,13 +159,53 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
||||||
{
|
{
|
||||||
var playerSession = GetOrCreatePlayerSession(playerId);
|
Debug.Log($"Handle player {playerId} debug report !");
|
||||||
playerSession.AddDebugReport(debugReport);
|
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
||||||
|
_currentPlayerSession.AddDebugReport(debugReport);
|
||||||
_debugReport = debugReport;
|
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
||||||
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
|
||||||
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
UpdateFrameView(_currentPlayerSession);
|
||||||
}
|
}
|
||||||
|
private void OnFrameSliderChange(int sliderValue)
|
||||||
|
{
|
||||||
|
if (_currentPlayerSession != null)
|
||||||
|
{
|
||||||
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
||||||
|
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnFrameLast_clicked()
|
||||||
|
{
|
||||||
|
if (_currentPlayerSession != null)
|
||||||
|
{
|
||||||
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
||||||
|
_frameSlider.value = _rangeIndex;
|
||||||
|
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnFrameNext_clicked()
|
||||||
|
{
|
||||||
|
if (_currentPlayerSession != null)
|
||||||
|
{
|
||||||
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
||||||
|
_frameSlider.value = _rangeIndex;
|
||||||
|
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnFrameClear_clicked()
|
||||||
|
{
|
||||||
|
if (_currentPlayerSession != null)
|
||||||
|
{
|
||||||
|
_frameSlider.label = $"Frame:";
|
||||||
|
_frameSlider.value = 0;
|
||||||
|
_frameSlider.lowValue = 0;
|
||||||
|
_frameSlider.highValue = 0;
|
||||||
|
_currentPlayerSession.ClearDebugReport();
|
||||||
|
_assetListViewer.ClearView();
|
||||||
|
_bundleListViewer.ClearView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
||||||
{
|
{
|
||||||
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
||||||
@@ -155,10 +219,26 @@ namespace YooAsset.Editor
|
|||||||
return newSession;
|
return newSession;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void RemovePlayerSession(int playerId)
|
private void UpdateFrameView(RemotePlayerSession playerSession)
|
||||||
{
|
{
|
||||||
if (_playerSessions.ContainsKey(playerId))
|
if (playerSession != null)
|
||||||
_playerSessions.Remove(playerId);
|
{
|
||||||
|
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
|
||||||
|
{
|
||||||
|
if (playerSession == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var debugReport = playerSession.GetDebugReport(rangeIndex);
|
||||||
|
if (debugReport != null)
|
||||||
|
{
|
||||||
|
_currentReport = debugReport;
|
||||||
|
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||||
|
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||||
|
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SampleBtn_onClick()
|
private void SampleBtn_onClick()
|
||||||
@@ -174,13 +254,13 @@ namespace YooAsset.Editor
|
|||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
{
|
{
|
||||||
_searchKeyWord = e.newValue;
|
_searchKeyWord = e.newValue;
|
||||||
if (_debugReport != null)
|
if (_currentReport != null)
|
||||||
{
|
{
|
||||||
_assetListViewer.FillViewData(_debugReport, _searchKeyWord);
|
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||||
_bundleListViewer.FillViewData(_debugReport, _searchKeyWord);
|
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ViewModeMenuAction(DropdownMenuAction action)
|
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var viewMode = (EViewMode)action.userData;
|
var viewMode = (EViewMode)action.userData;
|
||||||
if (_viewMode != viewMode)
|
if (_viewMode != viewMode)
|
||||||
@@ -188,11 +268,24 @@ namespace YooAsset.Editor
|
|||||||
_viewMode = viewMode;
|
_viewMode = viewMode;
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
_viewModeMenu.text = viewMode.ToString();
|
_viewModeMenu.text = viewMode.ToString();
|
||||||
_assetListViewer.AttachParent(root);
|
|
||||||
_bundleListViewer.DetachParent();
|
if (viewMode == EViewMode.AssetView)
|
||||||
|
{
|
||||||
|
_assetListViewer.AttachParent(root);
|
||||||
|
_bundleListViewer.DetachParent();
|
||||||
|
}
|
||||||
|
else if (viewMode == EViewMode.BundleView)
|
||||||
|
{
|
||||||
|
_assetListViewer.DetachParent();
|
||||||
|
_bundleListViewer.AttachParent(root);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException(viewMode.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun(DropdownMenuAction action)
|
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var viewMode = (EViewMode)action.userData;
|
var viewMode = (EViewMode)action.userData;
|
||||||
if (_viewMode == viewMode)
|
if (_viewMode == viewMode)
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||||
<uie:Toolbar name="Toolbar" style="display: flex;">
|
<uie:Toolbar name="TopToolbar" style="display: flex;">
|
||||||
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: middle-left; padding-left: 5px;" />
|
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: middle-left; padding-left: 5px;" />
|
||||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
||||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
|
<uie:Toolbar name="FrameToolbar">
|
||||||
|
<ui:SliderInt picking-mode="Ignore" label="Frame:" value="42" high-value="100" name="FrameSlider" style="flex-grow: 1;" />
|
||||||
|
<uie:ToolbarButton text=" << " display-tooltip-when-elided="true" name="FrameLast" />
|
||||||
|
<uie:ToolbarButton text=" >> " display-tooltip-when-elided="true" name="FrameNext" />
|
||||||
|
<uie:ToolbarButton text="Clear" display-tooltip-when-elided="true" name="FrameClear" />
|
||||||
|
</uie:Toolbar>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -18,6 +18,24 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int MaxReportCount { private set; get; }
|
public int MaxReportCount { private set; get; }
|
||||||
|
|
||||||
|
public int MinRangeValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int MaxRangeValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
int index = _reportList.Count - 1;
|
||||||
|
if (index < 0)
|
||||||
|
index = 0;
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
||||||
{
|
{
|
||||||
@@ -25,6 +43,14 @@ namespace YooAsset.Editor
|
|||||||
MaxReportCount = maxReportCount;
|
MaxReportCount = maxReportCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理缓存数据
|
||||||
|
/// </summary>
|
||||||
|
public void ClearDebugReport()
|
||||||
|
{
|
||||||
|
_reportList.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个调试报告
|
/// 添加一个调试报告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -39,13 +65,29 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取最近一次的报告
|
/// 获取调试报告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DebugReport GetLatestReport()
|
public DebugReport GetDebugReport(int rangeIndex)
|
||||||
{
|
{
|
||||||
if (_reportList.Count == 0)
|
if (_reportList.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
return _reportList[_reportList.Count - 1];
|
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
|
||||||
|
return null;
|
||||||
|
return _reportList[rangeIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 规范索引值
|
||||||
|
/// </summary>
|
||||||
|
public int ClampRangeIndex(int rangeIndex)
|
||||||
|
{
|
||||||
|
if (rangeIndex < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (rangeIndex > MaxRangeValue)
|
||||||
|
return MaxRangeValue;
|
||||||
|
|
||||||
|
return rangeIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,18 @@ namespace YooAsset.Editor
|
|||||||
_dependListView.bindItem = BindDependListViewItem;
|
_dependListView.bindItem = BindDependListViewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空页面
|
||||||
|
/// </summary>
|
||||||
|
public void ClearView()
|
||||||
|
{
|
||||||
|
_debugReport = null;
|
||||||
|
_assetListView.Clear();
|
||||||
|
_assetListView.ClearSelection();
|
||||||
|
_assetListView.itemsSource.Clear();
|
||||||
|
_assetListView.Rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 填充页面数据
|
/// 填充页面数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -46,6 +46,18 @@ namespace YooAsset.Editor
|
|||||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||||
_usingListView.bindItem = BindIncludeListViewItem;
|
_usingListView.bindItem = BindIncludeListViewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空页面
|
||||||
|
/// </summary>
|
||||||
|
public void ClearView()
|
||||||
|
{
|
||||||
|
_debugReport = null;
|
||||||
|
_bundleListView.Clear();
|
||||||
|
_bundleListView.ClearSelection();
|
||||||
|
_bundleListView.itemsSource.Clear();
|
||||||
|
_bundleListView.Rebuild();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 填充页面数据
|
/// 填充页面数据
|
||||||
|
|||||||
@@ -10,12 +10,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
private static readonly List<AssetBundleLoaderBase> _loaders = new List<AssetBundleLoaderBase>(1000);
|
private static readonly List<AssetBundleLoaderBase> _loaders = new List<AssetBundleLoaderBase>(1000);
|
||||||
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
|
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
|
||||||
private static readonly HashSet<AssetOperationHandle> _trackGameObjectHandles = new HashSet<AssetOperationHandle>();
|
|
||||||
private static readonly Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100);
|
private static readonly Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100);
|
||||||
|
|
||||||
private static bool _simulationOnEditor;
|
private static bool _simulationOnEditor;
|
||||||
private static int _loadingMaxNumber;
|
private static int _loadingMaxNumber;
|
||||||
|
|
||||||
public static bool AutoReleaseGameObjectHandle { private set; get; }
|
|
||||||
public static IDecryptionServices DecryptionServices { private set; get; }
|
public static IDecryptionServices DecryptionServices { private set; get; }
|
||||||
public static IBundleServices BundleServices { private set; get; }
|
public static IBundleServices BundleServices { private set; get; }
|
||||||
|
|
||||||
@@ -24,11 +22,10 @@ namespace YooAsset
|
|||||||
/// 初始化
|
/// 初始化
|
||||||
/// 注意:在使用AssetSystem之前需要初始化
|
/// 注意:在使用AssetSystem之前需要初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Initialize(bool simulationOnEditor, int loadingMaxNumber, bool autoReleaseGameObjectHandle, IDecryptionServices decryptionServices, IBundleServices bundleServices)
|
public static void Initialize(bool simulationOnEditor, int loadingMaxNumber, IDecryptionServices decryptionServices, IBundleServices bundleServices)
|
||||||
{
|
{
|
||||||
_simulationOnEditor = simulationOnEditor;
|
_simulationOnEditor = simulationOnEditor;
|
||||||
_loadingMaxNumber = loadingMaxNumber;
|
_loadingMaxNumber = loadingMaxNumber;
|
||||||
AutoReleaseGameObjectHandle = autoReleaseGameObjectHandle;
|
|
||||||
DecryptionServices = decryptionServices;
|
DecryptionServices = decryptionServices;
|
||||||
BundleServices = bundleServices;
|
BundleServices = bundleServices;
|
||||||
}
|
}
|
||||||
@@ -84,11 +81,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void UnloadUnusedAssets()
|
public static void UnloadUnusedAssets()
|
||||||
{
|
{
|
||||||
if (AutoReleaseGameObjectHandle)
|
|
||||||
{
|
|
||||||
CheckAutoReleaseGameObjectHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_simulationOnEditor)
|
if (_simulationOnEditor)
|
||||||
{
|
{
|
||||||
for (int i = _providers.Count - 1; i >= 0; i--)
|
for (int i = _providers.Count - 1; i >= 0; i--)
|
||||||
@@ -229,29 +221,6 @@ namespace YooAsset
|
|||||||
return provider.CreateHandle<SubAssetsOperationHandle>();
|
return provider.CreateHandle<SubAssetsOperationHandle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加自动释放的游戏对象句柄
|
|
||||||
/// </summary>
|
|
||||||
public static void AddAutoReleaseGameObjectHandle(AssetOperationHandle handle)
|
|
||||||
{
|
|
||||||
if (_trackGameObjectHandles.Contains(handle) == false)
|
|
||||||
_trackGameObjectHandles.Add(handle);
|
|
||||||
}
|
|
||||||
private static void CheckAutoReleaseGameObjectHandle()
|
|
||||||
{
|
|
||||||
List<AssetOperationHandle> removeList = new List<AssetOperationHandle>();
|
|
||||||
foreach (var trackHandle in _trackGameObjectHandles)
|
|
||||||
{
|
|
||||||
trackHandle.CheckAutoReleaseHandle();
|
|
||||||
if (trackHandle.IsValidNoWarning == false)
|
|
||||||
removeList.Add(trackHandle);
|
|
||||||
}
|
|
||||||
foreach (var removeHandle in removeList)
|
|
||||||
{
|
|
||||||
_trackGameObjectHandles.Remove(removeHandle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void UnloadSubScene(ProviderBase provider)
|
internal static void UnloadSubScene(ProviderBase provider)
|
||||||
{
|
{
|
||||||
string providerGUID = provider.MainAssetInfo.ProviderGUID;
|
string providerGUID = provider.MainAssetInfo.ProviderGUID;
|
||||||
|
|||||||
@@ -50,6 +50,17 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源对象
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TAsset">资源类型</typeparam>
|
||||||
|
public TAsset GetAssetObject<TAsset>() where TAsset : UnityEngine.Object
|
||||||
|
{
|
||||||
|
if (IsValid == false)
|
||||||
|
return null;
|
||||||
|
return Provider.AssetObject as TAsset;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 等待异步执行完毕
|
/// 等待异步执行完毕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -133,57 +144,13 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, parent);
|
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AssetSystem.AutoReleaseGameObjectHandle)
|
|
||||||
{
|
|
||||||
AddTrackGameObject(result);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
|
private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
|
||||||
{
|
{
|
||||||
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent, setPositionRotation);
|
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent, setPositionRotation);
|
||||||
OperationSystem.StartOperaiton(operation);
|
OperationSystem.StartOperaiton(operation);
|
||||||
|
|
||||||
if (AssetSystem.AutoReleaseGameObjectHandle)
|
|
||||||
{
|
|
||||||
operation.Completed += InstantiateOperationCompleted;
|
|
||||||
}
|
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 资源对象句柄相关
|
|
||||||
private readonly HashSet<GameObject> _trackGameObjects = new HashSet<GameObject>();
|
|
||||||
private void InstantiateOperationCompleted(AsyncOperationBase obj)
|
|
||||||
{
|
|
||||||
if (obj.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
var op = obj as InstantiateOperation;
|
|
||||||
AddTrackGameObject(op.Result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void AddTrackGameObject(GameObject go)
|
|
||||||
{
|
|
||||||
if (go != null)
|
|
||||||
{
|
|
||||||
_trackGameObjects.Add(go);
|
|
||||||
AssetSystem.AddAutoReleaseGameObjectHandle(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal void CheckAutoReleaseHandle()
|
|
||||||
{
|
|
||||||
if (IsValidNoWarning == false)
|
|
||||||
return;
|
|
||||||
if (_trackGameObjects.Count == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var go in _trackGameObjects)
|
|
||||||
{
|
|
||||||
if (go != null)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ReleaseInternal();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,15 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal abstract void InvokeCallback();
|
internal abstract void InvokeCallback();
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源信息
|
||||||
|
/// </summary>
|
||||||
|
public AssetInfo GetAssetInfo()
|
||||||
|
{
|
||||||
|
return _assetInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前状态
|
/// 当前状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -119,11 +119,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 错误信息
|
|
||||||
/// </summary>
|
|
||||||
public string Error { private set; get; }
|
|
||||||
|
|
||||||
|
|
||||||
private BundleInfo()
|
private BundleInfo()
|
||||||
{
|
{
|
||||||
@@ -136,7 +131,6 @@ namespace YooAsset
|
|||||||
RemoteMainURL = mainURL;
|
RemoteMainURL = mainURL;
|
||||||
RemoteFallbackURL = fallbackURL;
|
RemoteFallbackURL = fallbackURL;
|
||||||
EditorAssetPath = string.Empty;
|
EditorAssetPath = string.Empty;
|
||||||
Error = string.Empty;
|
|
||||||
}
|
}
|
||||||
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath)
|
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath)
|
||||||
{
|
{
|
||||||
@@ -146,7 +140,6 @@ namespace YooAsset
|
|||||||
RemoteMainURL = string.Empty;
|
RemoteMainURL = string.Empty;
|
||||||
RemoteFallbackURL = string.Empty;
|
RemoteFallbackURL = string.Empty;
|
||||||
EditorAssetPath = editorAssetPath;
|
EditorAssetPath = editorAssetPath;
|
||||||
Error = string.Empty;
|
|
||||||
}
|
}
|
||||||
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
||||||
{
|
{
|
||||||
@@ -156,17 +149,6 @@ namespace YooAsset
|
|||||||
RemoteMainURL = string.Empty;
|
RemoteMainURL = string.Empty;
|
||||||
RemoteFallbackURL = string.Empty;
|
RemoteFallbackURL = string.Empty;
|
||||||
EditorAssetPath = string.Empty;
|
EditorAssetPath = string.Empty;
|
||||||
Error = string.Empty;
|
|
||||||
}
|
|
||||||
public BundleInfo(string error)
|
|
||||||
{
|
|
||||||
_patchBundle = null;
|
|
||||||
LoadMode = ELoadMode.None;
|
|
||||||
BundleName = string.Empty;
|
|
||||||
RemoteMainURL = string.Empty;
|
|
||||||
RemoteFallbackURL = string.Empty;
|
|
||||||
EditorAssetPath = string.Empty;
|
|
||||||
Error = error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -137,12 +137,14 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
InitCache,
|
InitCache,
|
||||||
Update,
|
LoadManifest,
|
||||||
|
CopyManifest,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
private readonly AppManifestLoader _appManifestLoader = new AppManifestLoader();
|
private readonly AppManifestLoader _appManifestLoader = new AppManifestLoader();
|
||||||
|
private readonly AppManifestCopyer _appManifestCopyer = new AppManifestCopyer();
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl)
|
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl)
|
||||||
@@ -176,10 +178,10 @@ namespace YooAsset
|
|||||||
// 更新缓存文件
|
// 更新缓存文件
|
||||||
CacheData.UpdateCache();
|
CacheData.UpdateCache();
|
||||||
}
|
}
|
||||||
_steps = ESteps.Update;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.Update)
|
if (_steps == ESteps.LoadManifest)
|
||||||
{
|
{
|
||||||
_appManifestLoader.Update();
|
_appManifestLoader.Update();
|
||||||
Progress = _appManifestLoader.Progress();
|
Progress = _appManifestLoader.Progress();
|
||||||
@@ -194,10 +196,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
||||||
_impl.SetLocalPatchManifest(_appManifestLoader.Result);
|
_impl.SetLocalPatchManifest(_appManifestLoader.Result);
|
||||||
|
_appManifestCopyer.Init(_appManifestLoader.StaticVersion);
|
||||||
|
_steps = ESteps.CopyManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CopyManifest)
|
||||||
|
{
|
||||||
|
_appManifestCopyer.Update();
|
||||||
|
if (_appManifestCopyer.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_appManifestCopyer.Result == false)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _appManifestCopyer.Error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,14 +236,12 @@ namespace YooAsset
|
|||||||
CheckStaticVersion,
|
CheckStaticVersion,
|
||||||
LoadAppManifest,
|
LoadAppManifest,
|
||||||
CheckAppManifest,
|
CheckAppManifest,
|
||||||
Succeed,
|
Done,
|
||||||
Failed,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ESteps _steps = ESteps.LoadStaticVersion;
|
private ESteps _steps = ESteps.LoadStaticVersion;
|
||||||
private UnityWebDataRequester _downloader1;
|
private UnityWebDataRequester _downloader1;
|
||||||
private UnityWebDataRequester _downloader2;
|
private UnityWebDataRequester _downloader2;
|
||||||
private int _staticVersion = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 错误日志
|
/// 错误日志
|
||||||
@@ -230,19 +249,21 @@ namespace YooAsset
|
|||||||
public string Error { private set; get; }
|
public string Error { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 补丁清单
|
/// 加载结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PatchManifest Result { private set; get; }
|
public PatchManifest Result { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置补丁清单版本号
|
||||||
|
/// </summary>
|
||||||
|
public int StaticVersion { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否已经完成
|
/// 是否已经完成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDone()
|
public bool IsDone()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.Succeed || _steps == ESteps.Failed)
|
return _steps == ESteps.Done;
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -255,6 +276,9 @@ namespace YooAsset
|
|||||||
return _downloader2.Progress();
|
return _downloader2.Progress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新流程
|
||||||
|
/// </summary>
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (IsDone())
|
if (IsDone())
|
||||||
@@ -278,11 +302,11 @@ namespace YooAsset
|
|||||||
if (_downloader1.HasError())
|
if (_downloader1.HasError())
|
||||||
{
|
{
|
||||||
Error = _downloader1.GetError();
|
Error = _downloader1.GetError();
|
||||||
_steps = ESteps.Failed;
|
_steps = ESteps.Done;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_staticVersion = int.Parse(_downloader1.GetText());
|
StaticVersion = int.Parse(_downloader1.GetText());
|
||||||
_steps = ESteps.LoadAppManifest;
|
_steps = ESteps.LoadAppManifest;
|
||||||
}
|
}
|
||||||
_downloader1.Dispose();
|
_downloader1.Dispose();
|
||||||
@@ -291,7 +315,7 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.LoadAppManifest)
|
if (_steps == ESteps.LoadAppManifest)
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Load application patch manifest.");
|
YooLogger.Log($"Load application patch manifest.");
|
||||||
string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.GetPatchManifestFileName(_staticVersion));
|
string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.GetPatchManifestFileName(StaticVersion));
|
||||||
string url = PathHelper.ConvertToWWWPath(filePath);
|
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||||
_downloader2 = new UnityWebDataRequester();
|
_downloader2 = new UnityWebDataRequester();
|
||||||
_downloader2.SendRequest(url);
|
_downloader2.SendRequest(url);
|
||||||
@@ -306,16 +330,108 @@ namespace YooAsset
|
|||||||
if (_downloader2.HasError())
|
if (_downloader2.HasError())
|
||||||
{
|
{
|
||||||
Error = _downloader2.GetError();
|
Error = _downloader2.GetError();
|
||||||
_steps = ESteps.Failed;
|
_steps = ESteps.Done;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 解析APP里的补丁清单
|
// 解析APP里的补丁清单
|
||||||
Result = PatchManifest.Deserialize(_downloader2.GetText());
|
Result = PatchManifest.Deserialize(_downloader2.GetText());
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Done;
|
||||||
}
|
}
|
||||||
_downloader2.Dispose();
|
_downloader2.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置补丁清单复制器
|
||||||
|
/// </summary>
|
||||||
|
internal class AppManifestCopyer
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
CopyAppManifest,
|
||||||
|
CheckAppManifest,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private ESteps _steps = ESteps.CopyAppManifest;
|
||||||
|
private UnityWebFileRequester _downloader1;
|
||||||
|
private int _staticVersion;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误日志
|
||||||
|
/// </summary>
|
||||||
|
public string Error { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拷贝结果
|
||||||
|
/// </summary>
|
||||||
|
public bool Result { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否已经完成
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDone()
|
||||||
|
{
|
||||||
|
return _steps == ESteps.Done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化流程
|
||||||
|
/// </summary>
|
||||||
|
public void Init(int staticVersion)
|
||||||
|
{
|
||||||
|
_staticVersion = staticVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新流程
|
||||||
|
/// </summary>
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (IsDone())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CopyAppManifest)
|
||||||
|
{
|
||||||
|
string destFilePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(_staticVersion));
|
||||||
|
if (File.Exists(destFilePath))
|
||||||
|
{
|
||||||
|
Result = true;
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Log($"Copy application patch manifest.");
|
||||||
|
string sourceFilePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.GetPatchManifestFileName(_staticVersion));
|
||||||
|
string url = PathHelper.ConvertToWWWPath(sourceFilePath);
|
||||||
|
_downloader1 = new UnityWebFileRequester();
|
||||||
|
_downloader1.SendRequest(url, destFilePath);
|
||||||
|
_steps = ESteps.CheckAppManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckAppManifest)
|
||||||
|
{
|
||||||
|
if (_downloader1.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_downloader1.HasError())
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
Error = _downloader1.GetError();
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = true;
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
}
|
||||||
|
_downloader1.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -69,6 +69,7 @@ namespace YooAsset
|
|||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private UnityWebDataRequester _downloader1;
|
private UnityWebDataRequester _downloader1;
|
||||||
private UnityWebDataRequester _downloader2;
|
private UnityWebDataRequester _downloader2;
|
||||||
|
private VerifyManager _verifyManager = new VerifyManager();
|
||||||
private float _verifyTime;
|
private float _verifyTime;
|
||||||
|
|
||||||
internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, int resourceVersion, int timeout)
|
internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, int resourceVersion, int timeout)
|
||||||
@@ -171,20 +172,20 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.InitVerifyingCache)
|
if (_steps == ESteps.InitVerifyingCache)
|
||||||
{
|
{
|
||||||
InitVerifyingCache();
|
_verifyManager.InitVerifyingCache(_impl.AppPatchManifest, _impl.LocalPatchManifest, false);
|
||||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||||
_steps = ESteps.UpdateVerifyingCache;
|
_steps = ESteps.UpdateVerifyingCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.UpdateVerifyingCache)
|
if (_steps == ESteps.UpdateVerifyingCache)
|
||||||
{
|
{
|
||||||
Progress = GetVerifyProgress();
|
Progress = _verifyManager.GetVerifyProgress();
|
||||||
if (UpdateVerifyingCache())
|
if (_verifyManager.UpdateVerifyingCache())
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||||
YooLogger.Log($"Verify result : Success {_verifySuccessCount}, Fail {_verifyFailCount}, Elapsed time {costTime} seconds");
|
YooLogger.Log($"Verify result : Success {_verifyManager.VerifySuccessCount}, Fail {_verifyManager.VerifyFailCount}, Elapsed time {costTime} seconds");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,8 +249,107 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region 多线程相关
|
/// <summary>
|
||||||
|
/// 网络模式的更新清单操作(弱联网)
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class HostPlayModeWeaklyUpdateManifestOperation : UpdateManifestOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
LoadSandboxManifestHash,
|
||||||
|
InitVerifyingCache,
|
||||||
|
UpdateVerifyingCache,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly HostPlayModeImpl _impl;
|
||||||
|
private readonly int _resourceVersion;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
private VerifyManager _verifyManager = new VerifyManager();
|
||||||
|
private float _verifyTime;
|
||||||
|
|
||||||
|
internal HostPlayModeWeaklyUpdateManifestOperation(HostPlayModeImpl impl, int resourceVersion)
|
||||||
|
{
|
||||||
|
_impl = impl;
|
||||||
|
_resourceVersion = resourceVersion;
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadSandboxManifestHash;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadSandboxManifestHash)
|
||||||
|
{
|
||||||
|
LoadSandboxPatchManifest(_resourceVersion);
|
||||||
|
_steps = ESteps.InitVerifyingCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.InitVerifyingCache)
|
||||||
|
{
|
||||||
|
if (_verifyManager.InitVerifyingCache(_impl.AppPatchManifest, _impl.LocalPatchManifest, true))
|
||||||
|
{
|
||||||
|
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||||
|
_steps = ESteps.UpdateVerifyingCache;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"The resource version {_resourceVersion} content is not complete !";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.UpdateVerifyingCache)
|
||||||
|
{
|
||||||
|
Progress = _verifyManager.GetVerifyProgress();
|
||||||
|
if (_verifyManager.UpdateVerifyingCache())
|
||||||
|
{
|
||||||
|
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||||
|
YooLogger.Log($"Verify result : Success {_verifyManager.VerifySuccessCount}, Fail {_verifyManager.VerifyFailCount}, Elapsed time {costTime} seconds");
|
||||||
|
if (_verifyManager.VerifyFailCount > 0)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"The resource version {_resourceVersion} content has verify failed file !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载沙盒内的补丁清单
|
||||||
|
/// 注意:在加载本地补丁清单之前,未验证过文件的哈希值
|
||||||
|
/// </summary>
|
||||||
|
private void LoadSandboxPatchManifest(int updateResourceVersion)
|
||||||
|
{
|
||||||
|
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
YooLogger.Log("Load sandbox patch manifest file.");
|
||||||
|
string jsonData = File.ReadAllText(filePath);
|
||||||
|
var sandboxPatchManifest = PatchManifest.Deserialize(jsonData);
|
||||||
|
_impl.SetLocalPatchManifest(sandboxPatchManifest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 本地缓存文件验证管理器
|
||||||
|
/// </summary>
|
||||||
|
internal class VerifyManager
|
||||||
|
{
|
||||||
private class ThreadInfo
|
private class ThreadInfo
|
||||||
{
|
{
|
||||||
public bool Result = false;
|
public bool Result = false;
|
||||||
@@ -267,13 +367,14 @@ namespace YooAsset
|
|||||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||||
private int _verifyMaxNum = 32;
|
private int _verifyMaxNum = 32;
|
||||||
private int _verifyTotalCount = 0;
|
private int _verifyTotalCount = 0;
|
||||||
private int _verifySuccessCount = 0;
|
|
||||||
private int _verifyFailCount = 0;
|
|
||||||
|
|
||||||
private void InitVerifyingCache()
|
public int VerifySuccessCount { private set; get; } = 0;
|
||||||
|
public int VerifyFailCount { private set; get; } = 0;
|
||||||
|
|
||||||
|
public bool InitVerifyingCache(PatchManifest appPatchManifest, PatchManifest localPatchManifest, bool weaklyUpdate)
|
||||||
{
|
{
|
||||||
// 遍历所有文件然后验证并缓存合法文件
|
// 遍历所有文件然后验证并缓存合法文件
|
||||||
foreach (var patchBundle in _impl.LocalPatchManifest.BundleList)
|
foreach (var patchBundle in localPatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||||
@@ -281,18 +382,27 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (_impl.AppPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (appPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查看文件是否存在
|
// 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性
|
||||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
if (weaklyUpdate)
|
||||||
if (File.Exists(filePath) == false)
|
{
|
||||||
continue;
|
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
||||||
|
if (File.Exists(filePath))
|
||||||
_waitingList.Add(patchBundle);
|
_waitingList.Add(patchBundle);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
_waitingList.Add(patchBundle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置同时验证的最大数
|
// 设置同时验证的最大数
|
||||||
@@ -300,8 +410,9 @@ namespace YooAsset
|
|||||||
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
||||||
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
||||||
_verifyTotalCount = _waitingList.Count;
|
_verifyTotalCount = _waitingList.Count;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
private bool UpdateVerifyingCache()
|
public bool UpdateVerifyingCache()
|
||||||
{
|
{
|
||||||
_syncContext.Update();
|
_syncContext.Update();
|
||||||
|
|
||||||
@@ -331,6 +442,13 @@ namespace YooAsset
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
public float GetVerifyProgress()
|
||||||
|
{
|
||||||
|
if (_verifyTotalCount == 0)
|
||||||
|
return 1f;
|
||||||
|
return (float)(VerifySuccessCount + VerifyFailCount) / _verifyTotalCount;
|
||||||
|
}
|
||||||
|
|
||||||
private bool RunThread(PatchBundle patchBundle)
|
private bool RunThread(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
||||||
@@ -348,24 +466,17 @@ namespace YooAsset
|
|||||||
ThreadInfo info = (ThreadInfo)obj;
|
ThreadInfo info = (ThreadInfo)obj;
|
||||||
if (info.Result)
|
if (info.Result)
|
||||||
{
|
{
|
||||||
_verifySuccessCount++;
|
VerifySuccessCount++;
|
||||||
DownloadSystem.CacheVerifyFile(info.Bundle.Hash, info.Bundle.BundleName);
|
DownloadSystem.CacheVerifyFile(info.Bundle.Hash, info.Bundle.BundleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_verifyFailCount++;
|
VerifyFailCount++;
|
||||||
YooLogger.Warning($"Failed to verify file : {info.FilePath}");
|
YooLogger.Warning($"Failed to verify file : {info.FilePath}");
|
||||||
if (File.Exists(info.FilePath))
|
if (File.Exists(info.FilePath))
|
||||||
File.Delete(info.FilePath);
|
File.Delete(info.FilePath);
|
||||||
}
|
}
|
||||||
_verifyingList.Remove(info.Bundle);
|
_verifyingList.Remove(info.Bundle);
|
||||||
}
|
}
|
||||||
private float GetVerifyProgress()
|
|
||||||
{
|
|
||||||
if (_verifyTotalCount == 0)
|
|
||||||
return 1f;
|
|
||||||
return (float)(_verifySuccessCount + _verifyFailCount) / _verifyTotalCount;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,16 @@ namespace YooAsset
|
|||||||
OperationSystem.StartOperaiton(operation);
|
OperationSystem.StartOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步更新补丁清单(弱联网)
|
||||||
|
/// </summary>
|
||||||
|
public UpdateManifestOperation WeaklyUpdatePatchManifestAsync(int resourceVersion)
|
||||||
|
{
|
||||||
|
var operation = new HostPlayModeWeaklyUpdateManifestOperation(this, resourceVersion);
|
||||||
|
OperationSystem.StartOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步更新资源包裹
|
/// 异步更新资源包裹
|
||||||
@@ -249,16 +259,60 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(AppPatchManifest, tags);
|
List<BundleInfo> unpcakList = GetUnpackListByTags(tags);
|
||||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
private List<BundleInfo> GetUnpackListByTags(string[] tags)
|
||||||
|
{
|
||||||
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
|
foreach (var patchBundle in AppPatchManifest.BundleList)
|
||||||
|
{
|
||||||
|
// 如果不是内置资源
|
||||||
|
if (patchBundle.IsBuildin == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 忽略缓存文件
|
||||||
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 查询DLC资源
|
||||||
|
if (patchBundle.HasTag(tags))
|
||||||
|
{
|
||||||
|
downloadList.Add(patchBundle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertToUnpackList(downloadList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建解压器
|
||||||
|
/// </summary>
|
||||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByAll(AppPatchManifest);
|
List<BundleInfo> unpcakList = GetUnpackListByAll();
|
||||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
private List<BundleInfo> GetUnpackListByAll()
|
||||||
|
{
|
||||||
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
|
foreach (var patchBundle in AppPatchManifest.BundleList)
|
||||||
|
{
|
||||||
|
// 如果不是内置资源
|
||||||
|
if (patchBundle.IsBuildin == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 忽略缓存文件
|
||||||
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
downloadList.Add(patchBundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertToUnpackList(downloadList);
|
||||||
|
}
|
||||||
|
|
||||||
// WEB相关
|
// WEB相关
|
||||||
public string GetPatchDownloadMainURL(string fileName)
|
public string GetPatchDownloadMainURL(string fileName)
|
||||||
@@ -290,6 +344,26 @@ namespace YooAsset
|
|||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解压相关
|
||||||
|
public List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
||||||
|
{
|
||||||
|
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
|
||||||
|
foreach (var patchBundle in unpackList)
|
||||||
|
{
|
||||||
|
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
||||||
|
result.Add(bundleInfo);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
||||||
|
{
|
||||||
|
// 注意:我们把流加载路径指定为远端下载地址
|
||||||
|
string streamingPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
||||||
|
streamingPath = PathHelper.ConvertToWWWPath(streamingPath);
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, streamingPath, streamingPath);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
// 设置资源清单
|
// 设置资源清单
|
||||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,22 +30,6 @@ namespace YooAsset
|
|||||||
return _appPatchManifest.ResourceVersion;
|
return _appPatchManifest.ResourceVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建解压器
|
|
||||||
/// </summary>
|
|
||||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
|
||||||
{
|
|
||||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(_appPatchManifest, tags);
|
|
||||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
|
||||||
{
|
|
||||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByAll(_appPatchManifest);
|
|
||||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置资源清单
|
// 设置资源清单
|
||||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -124,72 +124,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static class PatchHelper
|
internal static class PatchHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 获取内置资源解压列表
|
|
||||||
/// </summary>
|
|
||||||
public static List<BundleInfo> GetUnpackListByTags(PatchManifest appPatchManifest, string[] tags)
|
|
||||||
{
|
|
||||||
// 注意:离线运行模式也依赖下面逻辑,所以判断沙盒内文件是否存在不能通过缓存系统去验证。
|
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
|
||||||
foreach (var patchBundle in appPatchManifest.BundleList)
|
|
||||||
{
|
|
||||||
// 如果已经在沙盒内
|
|
||||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
|
||||||
if (System.IO.File.Exists(filePath))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// 如果不是内置资源
|
|
||||||
if (patchBundle.IsBuildin == false)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// 查询DLC资源
|
|
||||||
if (patchBundle.HasTag(tags))
|
|
||||||
{
|
|
||||||
downloadList.Add(patchBundle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ConvertToUnpackList(downloadList);
|
|
||||||
}
|
|
||||||
public static List<BundleInfo> GetUnpackListByAll(PatchManifest appPatchManifest)
|
|
||||||
{
|
|
||||||
// 注意:离线运行模式也依赖下面逻辑,所以判断沙盒内文件是否存在不能通过缓存系统去验证。
|
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
|
||||||
foreach (var patchBundle in appPatchManifest.BundleList)
|
|
||||||
{
|
|
||||||
// 如果已经在沙盒内
|
|
||||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
|
||||||
if (System.IO.File.Exists(filePath))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// 如果不是内置资源
|
|
||||||
if (patchBundle.IsBuildin == false)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
downloadList.Add(patchBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ConvertToUnpackList(downloadList);
|
|
||||||
}
|
|
||||||
private static List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
|
||||||
{
|
|
||||||
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
|
|
||||||
foreach (var patchBundle in unpackList)
|
|
||||||
{
|
|
||||||
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
|
||||||
result.Add(bundleInfo);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
private static BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
|
||||||
{
|
|
||||||
// 注意:我们把流加载路径指定为远端下载地址
|
|
||||||
string streamingPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
|
||||||
streamingPath = PathHelper.ConvertToWWWPath(streamingPath);
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, streamingPath, streamingPath);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源信息列表
|
/// 获取资源信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -40,12 +40,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LocationToLower = false;
|
public bool LocationToLower = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自动释放游戏对象所属资源句柄
|
|
||||||
/// 说明:通过资源句柄实例化的游戏对象在销毁之后,会自动释放所属资源句柄。
|
|
||||||
/// </summary>
|
|
||||||
public bool AutoReleaseGameObjectHandle = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位服务接口
|
/// 资源定位服务接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -91,11 +85,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class HostPlayModeParameters : InitializeParameters
|
public class HostPlayModeParameters : InitializeParameters
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 当缓存池被污染的时候清理缓存池
|
|
||||||
/// </summary>
|
|
||||||
public bool ClearCacheWhenDirty;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认的资源服务器下载地址
|
/// 默认的资源服务器下载地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -106,6 +95,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string FallbackHostServer;
|
public string FallbackHostServer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当缓存池被污染的时候清理缓存池
|
||||||
|
/// </summary>
|
||||||
|
public bool ClearCacheWhenDirty = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用断点续传功能的文件大小
|
/// 启用断点续传功能的文件大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -214,7 +208,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_editorSimulateModeImpl = new EditorSimulateModeImpl();
|
_editorSimulateModeImpl = new EditorSimulateModeImpl();
|
||||||
_bundleServices = _editorSimulateModeImpl;
|
_bundleServices = _editorSimulateModeImpl;
|
||||||
AssetSystem.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.AutoReleaseGameObjectHandle, parameters.DecryptionServices, _bundleServices);
|
AssetSystem.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
||||||
initializeOperation = _editorSimulateModeImpl.InitializeAsync(
|
initializeOperation = _editorSimulateModeImpl.InitializeAsync(
|
||||||
editorSimulateModeParameters.LocationToLower,
|
editorSimulateModeParameters.LocationToLower,
|
||||||
@@ -224,14 +218,14 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_offlinePlayModeImpl = new OfflinePlayModeImpl();
|
_offlinePlayModeImpl = new OfflinePlayModeImpl();
|
||||||
_bundleServices = _offlinePlayModeImpl;
|
_bundleServices = _offlinePlayModeImpl;
|
||||||
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.AutoReleaseGameObjectHandle, parameters.DecryptionServices, _bundleServices);
|
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
initializeOperation = _offlinePlayModeImpl.InitializeAsync(parameters.LocationToLower);
|
initializeOperation = _offlinePlayModeImpl.InitializeAsync(parameters.LocationToLower);
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
_hostPlayModeImpl = new HostPlayModeImpl();
|
_hostPlayModeImpl = new HostPlayModeImpl();
|
||||||
_bundleServices = _hostPlayModeImpl;
|
_bundleServices = _hostPlayModeImpl;
|
||||||
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.AutoReleaseGameObjectHandle, parameters.DecryptionServices, _bundleServices);
|
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
||||||
initializeOperation = _hostPlayModeImpl.InitializeAsync(
|
initializeOperation = _hostPlayModeImpl.InitializeAsync(
|
||||||
hostPlayModeParameters.LocationToLower,
|
hostPlayModeParameters.LocationToLower,
|
||||||
@@ -313,6 +307,36 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 弱联网情况下加载补丁清单
|
||||||
|
/// 注意:当指定版本内容验证失败后会返回失败。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="resourceVersion">指定的资源版本</param>
|
||||||
|
public static UpdateManifestOperation WeaklyUpdateManifestAsync(int resourceVersion)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
|
{
|
||||||
|
var operation = new EditorPlayModeUpdateManifestOperation();
|
||||||
|
OperationSystem.StartOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
|
{
|
||||||
|
var operation = new OfflinePlayModeUpdateManifestOperation();
|
||||||
|
OperationSystem.StartOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
|
{
|
||||||
|
return _hostPlayModeImpl.WeaklyUpdatePatchManifestAsync(resourceVersion);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开启一个异步操作
|
/// 开启一个异步操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -512,6 +536,15 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
|
if (bundleInfo.IsRawFile == false)
|
||||||
|
{
|
||||||
|
string error = $"Cannot load asset bundle file using {nameof(GetRawFileAsync)} interfaces !";
|
||||||
|
YooLogger.Warning(error);
|
||||||
|
RawFileOperation operation = new CompletedRawFileOperation(error, copyPath);
|
||||||
|
OperationSystem.StartOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
||||||
@@ -847,7 +880,9 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
return _offlinePlayModeImpl.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||||
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
@@ -875,7 +910,9 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
return _offlinePlayModeImpl.CreatePatchUnpackerByAll(unpackingMaxNumber, failedTryAgain);
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||||
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system",
|
"description": "unity3d resources management system",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -114,7 +114,8 @@ private static void BuildInternal(BuildTarget buildTarget)
|
|||||||
buildParameters.BuildinTags = "buildin";
|
buildParameters.BuildinTags = "buildin";
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.EnableAddressable = false;
|
buildParameters.EnableAddressable = false;
|
||||||
buildParameters.AppendFileExtension = false;
|
buildParameters.AppendFileExtension = false;
|
||||||
|
buildParameters.CopyBuildinTagFiles = true;
|
||||||
buildParameters.EncryptionServices = new GameEncryption();
|
buildParameters.EncryptionServices = new GameEncryption();
|
||||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,25 @@
|
|||||||
|
|
||||||
#### 资源分组
|
#### 资源分组
|
||||||
|
|
||||||
|
- Active Rule
|
||||||
|
|
||||||
|
激活规则,规则可以自定义扩展。下面是内置规则:
|
||||||
|
|
||||||
|
- EnableGroup 启用分组。
|
||||||
|
|
||||||
|
- DisableGroup 禁用分组。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
//自定义扩展范例
|
||||||
|
public class DisableGroup : IActiveRule
|
||||||
|
{
|
||||||
|
public bool IsActiveGroup()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
- Grouper Name
|
- Grouper Name
|
||||||
|
|
||||||
分组名称
|
分组名称
|
||||||
@@ -63,6 +82,7 @@
|
|||||||
- AddressByCollectorAndFileName 以收集器名+文件名为定位地址。
|
- AddressByCollectorAndFileName 以收集器名+文件名为定位地址。
|
||||||
|
|
||||||
````c#
|
````c#
|
||||||
|
//自定义扩展范例
|
||||||
public class AddressByFileName : IAddressRule
|
public class AddressByFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
# 调试器
|
# 调试器
|
||||||
|
|
||||||
调试器是在游戏运行时,帮助我们查看资源包加载信息的工具。可以查看资源对象列表信息(AssetView),资源包列表信息(BundleView)。
|
调试器是在游戏运行时,帮助我们查看资源包加载信息的工具,通过该工具可以发现潜在的资源泄漏。
|
||||||
|
|
||||||
未来计划支持在编辑器下通过远程调试真机信息。
|
可以查看资源对象列表信息(AssetView),资源包列表信息(BundleView)。
|
||||||
|
|
||||||
**注意**:该工具仅支持Unity2019+
|
**注意**:该工具仅支持Unity2019+
|
||||||
|
|
||||||
|
### 真机远程调试注意事项
|
||||||
|
|
||||||
|
在构建安装包的时候,需要勾选上Development Build和Autoconnect Profiler
|
||||||
|
|
||||||
### 资源对象列表视图
|
### 资源对象列表视图
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
````C#
|
````C#
|
||||||
// 资源系统初始化方法,根据不同的模式,我们传递不同的创建参数类
|
// 资源系统初始化方法,根据不同的模式,我们传递不同的创建参数类
|
||||||
YooAssets.InitializeAsync(CreateParameters parameters);
|
YooAssets.InitializeAsync(InitializeParameters parameters);
|
||||||
````
|
````
|
||||||
|
|
||||||
**编辑器模拟模式**
|
**编辑器模拟模式**
|
||||||
@@ -16,9 +16,9 @@ YooAssets.InitializeAsync(CreateParameters parameters);
|
|||||||
````c#
|
````c#
|
||||||
private IEnumerator InitializeYooAsset()
|
private IEnumerator InitializeYooAsset()
|
||||||
{
|
{
|
||||||
var createParameters = new YooAssets.EditorSimulateModeParameters();
|
var initParameters = new YooAssets.EditorSimulateModeParameters();
|
||||||
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||||
yield return YooAssets.InitializeAsync(createParameters);
|
yield return YooAssets.InitializeAsync(initParameters);
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
@@ -31,9 +31,9 @@ private IEnumerator InitializeYooAsset()
|
|||||||
````c#
|
````c#
|
||||||
private IEnumerator InitializeYooAsset()
|
private IEnumerator InitializeYooAsset()
|
||||||
{
|
{
|
||||||
var createParameters = new YooAssets.OfflinePlayModeParameters();
|
var initParameters = new YooAssets.OfflinePlayModeParameters();
|
||||||
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||||
yield return YooAssets.InitializeAsync(createParameters);
|
yield return YooAssets.InitializeAsync(initParameters);
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
@@ -59,16 +59,19 @@ private IEnumerator InitializeYooAsset()
|
|||||||
|
|
||||||
- FallbackHostServer : 备用的资源服务器IP地址。
|
- FallbackHostServer : 备用的资源服务器IP地址。
|
||||||
|
|
||||||
|
- VerifyLevel : 下载文件校验等级
|
||||||
|
|
||||||
````c#
|
````c#
|
||||||
private IEnumerator InitializeYooAsset()
|
private IEnumerator InitializeYooAsset()
|
||||||
{
|
{
|
||||||
var createParameters = new YooAssets.HostPlayModeParameters();
|
var initParameters = new YooAssets.HostPlayModeParameters();
|
||||||
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||||
createParameters.DecryptionServices = null;
|
initParameters.DecryptionServices = null;
|
||||||
createParameters.ClearCacheWhenDirty = false;
|
initParameters.ClearCacheWhenDirty = false;
|
||||||
createParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android";
|
initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android";
|
||||||
createParameters.FallbackHostServer = "http://127.0.0.1/CDN2/Android";
|
initParameters.FallbackHostServer = "http://127.0.0.1/CDN2/Android";
|
||||||
yield return YooAssets.InitializeAsync(createParameters);
|
initParameters.VerifyLevel = EVerifyLevel.High;
|
||||||
|
yield return YooAssets.InitializeAsync(initParameters);
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|||||||
@@ -86,9 +86,10 @@ IEnumerator Download()
|
|||||||
long totalDownloadBytes = downloader.TotalDownloadBytes;
|
long totalDownloadBytes = downloader.TotalDownloadBytes;
|
||||||
|
|
||||||
//注册回调方法
|
//注册回调方法
|
||||||
downloader.OnDownloadFileFailedCallback = OneDownloadFileFailed;
|
downloader.OnDownloadErrorCallback = OnDownloadErrorFunction;
|
||||||
downloader.OnDownloadProgressCallback = OnDownloadProgressUpdate;
|
downloader.OnDownloadProgressCallback = OnDownloadProgressUpdateFunction;
|
||||||
downloader.OnDownloadOverCallback = OnDownloadOver;
|
downloader.OnDownloadOverCallback = OnDownloadOverFunction;
|
||||||
|
downloader.OnStartDownloadFileCallback = OnStartDownloadFileFunction;
|
||||||
|
|
||||||
//开启下载
|
//开启下载
|
||||||
downloader.BeginDownload();
|
downloader.BeginDownload();
|
||||||
@@ -106,5 +107,48 @@ IEnumerator Download()
|
|||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
**弱联网更新解决方案**
|
||||||
|
|
||||||
|
对于偏单机但是也有资源热更需求的项目。当玩家本地网络不稳定或无网络的时候,我们又不希望玩家卡在资源更新步骤而不能正常游戏。所以当玩家本地网络有问题的时候,我们可以跳过资源更新的步骤。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
private IEnumerator UpdateStaticVersion()
|
||||||
|
{
|
||||||
|
UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync(10);
|
||||||
|
yield return operation;
|
||||||
|
if (operation.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
// 如果获取远端资源版本成功,说明当前网络连接并无问题,可以走正常更新流程。
|
||||||
|
......
|
||||||
|
|
||||||
|
// 注意:在成功下载所有资源之后,我们需要记录当前最新的资源版本号
|
||||||
|
PlayerPrefs.SetInt("STATIC_VERSION", resourceVersion);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 如果获取远端资源版本失败,我们走弱联网更新模式。
|
||||||
|
// 注意:如果从来没有保存过版本信息,则需要从内部读取StaticVersion.bytes文件的版本信息。
|
||||||
|
int staticVersion = PlayerPrefs.GetInt("STATIC_VERSION", -1);
|
||||||
|
if (staticVersion == -1)
|
||||||
|
{
|
||||||
|
staticVersion = LoadStaticVersionFromStreamingAssets();
|
||||||
|
PlayerPrefs.SetInt("STATIC_VERSION", staticVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在弱联网情况下更新补丁清单
|
||||||
|
UpdateManifestOperation operation2 = YooAssets.WeaklyUpdateManifestAsync(staticVersion);
|
||||||
|
yield return operation2;
|
||||||
|
if (operation2.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
StartGame();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 指定版本的资源内容本地并不完整,需要提示玩家更新。
|
||||||
|
ShowMessageBox("请检查本地网络,有新的游戏内容需要更新!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,42 @@
|
|||||||
# 资源加载
|
# 资源加载
|
||||||
|
|
||||||
加载方法:
|
**加载方法**
|
||||||
|
|
||||||
- YooAssets.LoadAssetSync() 同步加载资源对象
|
- YooAssets.LoadAssetSync() 同步加载资源对象
|
||||||
- YooAssets.LoadSubAssetsSync() 同步加载子资源对象
|
|
||||||
- YooAssets.LoadAssetAsync() 异步加载资源对象
|
- YooAssets.LoadAssetAsync() 异步加载资源对象
|
||||||
|
- YooAssets.LoadSubAssetsSync() 同步加载子资源对象
|
||||||
- YooAssets.LoadSubAssetsAsync() 异步加载子资源对象
|
- YooAssets.LoadSubAssetsAsync() 异步加载子资源对象
|
||||||
- YooAssets.LoadSceneAsync() 异步加载场景
|
- YooAssets.LoadSceneAsync() 异步加载场景
|
||||||
- YooAssets.GetRawFileAsync() 异步获取原生文件
|
- YooAssets.GetRawFileAsync() 异步获取原生文件
|
||||||
|
|
||||||
统一约定:location为资源的定位地址,也是加载资源对象的唯一标识符。
|
**统一约定**
|
||||||
|
|
||||||
DefaultLocationServices 默认资源定位服务,location代表的是资源对象的相对路径。
|
**Location**为资源的定位地址,也是加载资源对象的唯一标识符。
|
||||||
|
|
||||||
AddressLocationServices 可寻址资源定位服务,location代表的是资源对象可寻址地址。
|
- DefaultLocationServices 默认资源定位服务,location代表的是资源对象的相对路径。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
|
||||||
|
// 设定资源路径的根目录为:"Assets/GameRes",后续加载的资源定位地址填写相对路径:"Audio/bgMusic"
|
||||||
|
var createParameters = new YooAssets.EditorSimulateModeParameters();
|
||||||
|
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||||
|
yield return YooAssets.InitializeAsync(createParameters);
|
||||||
|
......
|
||||||
|
YooAssets.LoadAssetAsync<AudioClip>("Audio/bgMusic");
|
||||||
|
```
|
||||||
|
|
||||||
|
- AddressLocationServices 可寻址资源定位服务,location代表的是资源对象可寻址地址。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
|
||||||
|
// 需要在资源配置界面启用可寻址功能(Enable Addressable)。
|
||||||
|
// 配置界面的可寻址规则为AddressByFileName,那么资源定位地址填写文件名称:"bgMusic"
|
||||||
|
var createParameters = new YooAssets.EditorSimulateModeParameters();
|
||||||
|
createParameters.LocationServices = new AddressLocationServices();
|
||||||
|
yield return YooAssets.InitializeAsync(createParameters);
|
||||||
|
......
|
||||||
|
YooAssets.LoadAssetAsync<AudioClip>("bgMusic");
|
||||||
|
````
|
||||||
|
|
||||||
**注意**:以下范例执行环境是在DefaultLocationServices下。
|
**注意**:以下范例执行环境是在DefaultLocationServices下。
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 87 KiB |
@@ -48,7 +48,7 @@
|
|||||||
## 入门教程
|
## 入门教程
|
||||||
1. [快速开始](https://github.com/tuyoogame/YooAsset/blob/master/Docs/QuickStart.md)
|
1. [快速开始](https://github.com/tuyoogame/YooAsset/blob/master/Docs/QuickStart.md)
|
||||||
2. [全局配置](https://github.com/tuyoogame/YooAsset/blob/master/Docs/Settings.md)
|
2. [全局配置](https://github.com/tuyoogame/YooAsset/blob/master/Docs/Settings.md)
|
||||||
3. [资源配置](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetGrouper.md)
|
3. [资源配置](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetCollector.md)
|
||||||
4. [资源打包](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetBuilder.md)
|
4. [资源打包](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetBuilder.md)
|
||||||
5. [资源部署](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetDeploy.md)
|
5. [资源部署](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetDeploy.md)
|
||||||
5. [构建报告](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetReporter.md)
|
5. [构建报告](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetReporter.md)
|
||||||
|
|||||||