Optimized the speed of simulate build.
优化了编辑器下模拟构建的速度。
This commit is contained in:
@@ -13,9 +13,9 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟运行的初始化操作
|
||||
/// 编辑器下模拟模式的初始化操作
|
||||
/// </summary>
|
||||
internal sealed class EditorPlayModeInitializationOperation : InitializationOperation
|
||||
internal sealed class EditorSimulateModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -24,10 +24,10 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorPlayModeImpl _impl;
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorPlayModeInitializationOperation(EditorPlayModeImpl impl)
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_steps == ESteps.Builder)
|
||||
{
|
||||
string manifestFilePath = EditorPlayModeHelper.DryRunBuild();
|
||||
string manifestFilePath = EditorSimulateModeHelper.SimulateBuild();
|
||||
if (string.IsNullOrEmpty(manifestFilePath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -65,7 +65,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线模式的初始化操作
|
||||
/// 离线运行模式的初始化操作
|
||||
/// </summary>
|
||||
internal sealed class OfflinePlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
@@ -116,7 +116,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 网络模式的初始化操作
|
||||
/// 网络运行模式的初始化操作
|
||||
/// </summary>
|
||||
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
|
||||
+7
-7
@@ -3,19 +3,19 @@ using System.Reflection;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal static class EditorPlayModeHelper
|
||||
internal static class EditorSimulateModeHelper
|
||||
{
|
||||
private static System.Type _classType;
|
||||
|
||||
public static string DryRunBuild()
|
||||
public static string SimulateBuild()
|
||||
{
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleRuntimeBuilder");
|
||||
InvokePublicStaticMethod(_classType, "FastBuild");
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleSimulateBuilder");
|
||||
InvokePublicStaticMethod(_classType, "SimulateBuild");
|
||||
return GetPatchManifestFilePath();
|
||||
}
|
||||
private static string GetPatchManifestFilePath()
|
||||
{
|
||||
return (string)InvokePublicStaticMethod(_classType, "GetPatchManifestFilePath");
|
||||
return (string)InvokePublicStaticMethod(_classType, "GetPatchManifestPath");
|
||||
}
|
||||
private static object InvokePublicStaticMethod(System.Type type, string method, params object[] parameters)
|
||||
{
|
||||
@@ -30,8 +30,8 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
#else
|
||||
internal static class EditorPlayModeHelper
|
||||
internal static class EditorSimulateModeHelper
|
||||
{
|
||||
public static string DryRunBuild() { throw new System.Exception("Only support in unity editor !"); }
|
||||
public static string SimulateBuild() { throw new System.Exception("Only support in unity editor !"); }
|
||||
}
|
||||
#endif
|
||||
+2
-2
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class EditorPlayModeImpl : IBundleServices
|
||||
internal class EditorSimulateModeImpl : IBundleServices
|
||||
{
|
||||
internal PatchManifest AppPatchManifest;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync()
|
||||
{
|
||||
var operation = new EditorPlayModeInitializationOperation(this);
|
||||
var operation = new EditorSimulateModeInitializationOperation(this);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
@@ -14,17 +14,18 @@ namespace YooAsset
|
||||
public enum EPlayMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 编辑器下模拟运行模式
|
||||
/// 编辑器下的模拟模式
|
||||
/// 注意:在初始化的时候自动构建真机运行环境。
|
||||
/// </summary>
|
||||
EditorPlayMode,
|
||||
|
||||
EditorSimulateMode,
|
||||
|
||||
/// <summary>
|
||||
/// 离线模式
|
||||
/// 离线运行模式
|
||||
/// </summary>
|
||||
OfflinePlayMode,
|
||||
|
||||
/// <summary>
|
||||
/// 网络模式
|
||||
/// 网络运行模式
|
||||
/// </summary>
|
||||
HostPlayMode,
|
||||
}
|
||||
@@ -56,21 +57,21 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟运行模式参数
|
||||
/// 编辑器下模拟运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class EditorPlayModeParameters : CreateParameters
|
||||
public class EditorSimulateModeParameters : CreateParameters
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线模式参数
|
||||
/// 离线运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class OfflinePlayModeParameters : CreateParameters
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 网络模式参数
|
||||
/// 网络运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class HostPlayModeParameters : CreateParameters
|
||||
{
|
||||
@@ -102,7 +103,7 @@ namespace YooAsset
|
||||
private static EPlayMode _playMode;
|
||||
private static IBundleServices _bundleServices;
|
||||
private static ILocationServices _locationServices;
|
||||
private static EditorPlayModeImpl _editorPlayModeImpl;
|
||||
private static EditorSimulateModeImpl _editorSimulateModeImpl;
|
||||
private static OfflinePlayModeImpl _offlinePlayModeImpl;
|
||||
private static HostPlayModeImpl _hostPlayModeImpl;
|
||||
|
||||
@@ -151,8 +152,8 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 运行模式
|
||||
if (parameters is EditorPlayModeParameters)
|
||||
_playMode = EPlayMode.EditorPlayMode;
|
||||
if (parameters is EditorSimulateModeParameters)
|
||||
_playMode = EPlayMode.EditorSimulateMode;
|
||||
else if (parameters is OfflinePlayModeParameters)
|
||||
_playMode = EPlayMode.OfflinePlayMode;
|
||||
else if (parameters is HostPlayModeParameters)
|
||||
@@ -176,12 +177,12 @@ namespace YooAsset
|
||||
|
||||
// 初始化资源系统
|
||||
InitializationOperation initializeOperation;
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
_editorPlayModeImpl = new EditorPlayModeImpl();
|
||||
_bundleServices = _editorPlayModeImpl;
|
||||
_editorSimulateModeImpl = new EditorSimulateModeImpl();
|
||||
_bundleServices = _editorSimulateModeImpl;
|
||||
AssetSystem.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||
initializeOperation = _editorPlayModeImpl.InitializeAsync();
|
||||
initializeOperation = _editorSimulateModeImpl.InitializeAsync();
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
@@ -223,7 +224,7 @@ namespace YooAsset
|
||||
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var operation = new EditorPlayModeUpdateStaticVersionOperation();
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
@@ -255,7 +256,7 @@ namespace YooAsset
|
||||
public static UpdateManifestOperation UpdateManifestAsync(int resourceVersion, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var operation = new EditorPlayModeUpdateManifestOperation();
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
@@ -285,11 +286,11 @@ namespace YooAsset
|
||||
public static int GetResourceVersion()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
if (_editorPlayModeImpl == null)
|
||||
if (_editorSimulateModeImpl == null)
|
||||
throw new Exception("YooAsset is not initialized.");
|
||||
return _editorPlayModeImpl.GetResourceVersion();
|
||||
return _editorSimulateModeImpl.GetResourceVersion();
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
@@ -574,7 +575,7 @@ namespace YooAsset
|
||||
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(bundleName);
|
||||
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
@@ -635,7 +636,7 @@ namespace YooAsset
|
||||
public static PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -661,7 +662,7 @@ namespace YooAsset
|
||||
public static PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -689,7 +690,7 @@ namespace YooAsset
|
||||
public static PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -723,7 +724,7 @@ namespace YooAsset
|
||||
public static PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
@@ -770,7 +771,7 @@ namespace YooAsset
|
||||
public static PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||
@@ -804,7 +805,7 @@ namespace YooAsset
|
||||
public static UpdatePackageOperation UpdatePackageAsync(int resourceVersion, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorPlayMode)
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var operation = new EditorPlayModeUpdatePackageOperation();
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
@@ -876,7 +877,11 @@ namespace YooAsset
|
||||
// 轮询更新资源系统
|
||||
AssetSystem.Update();
|
||||
}
|
||||
internal static string MappingToAssetPath(string location)
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址转换为资源完整路径
|
||||
/// </summary>
|
||||
public static string MappingToAssetPath(string location)
|
||||
{
|
||||
DebugCheckLocation(location);
|
||||
return _bundleServices.MappingToAssetPath(location);
|
||||
|
||||
Reference in New Issue
Block a user