Support fast build mode.
支持快速构建模式,真实的实现EditorPlayMode的运行时环境。
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Reflection;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal static class EditorPlayModeHelper
|
||||
{
|
||||
private static System.Type _classType;
|
||||
|
||||
public static string DryRunBuild()
|
||||
{
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleRuntimeBuilder");
|
||||
InvokePublicStaticMethod(_classType, "FastBuild");
|
||||
return GetPatchManifestFilePath();
|
||||
}
|
||||
private static string GetPatchManifestFilePath()
|
||||
{
|
||||
return (string)InvokePublicStaticMethod(_classType, "GetPatchManifestFilePath");
|
||||
}
|
||||
private static object InvokePublicStaticMethod(System.Type type, string method, params object[] parameters)
|
||||
{
|
||||
var methodInfo = type.GetMethod(method, BindingFlags.Public | BindingFlags.Static);
|
||||
if (methodInfo == null)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"{type.FullName} not found method : {method}");
|
||||
return null;
|
||||
}
|
||||
return methodInfo.Invoke(null, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
internal static class EditorPlayModeHelper
|
||||
{
|
||||
public static string DryRunBuild() { throw new System.Exception("Only support in unity editor !"); }
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b09fe4b7aa2d2143bc538976541b039
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,12 +6,14 @@ namespace YooAsset
|
||||
{
|
||||
internal class EditorPlayModeImpl : IBundleServices
|
||||
{
|
||||
internal PatchManifest AppPatchManifest;
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync()
|
||||
{
|
||||
var operation = new EditorPlayModeInitializationOperation();
|
||||
var operation = new EditorPlayModeInitializationOperation(this);
|
||||
OperationSystem.ProcessOperaiton(operation);
|
||||
return operation;
|
||||
}
|
||||
@@ -21,27 +23,41 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public int GetResourceVersion()
|
||||
{
|
||||
return 0;
|
||||
if (AppPatchManifest == null)
|
||||
return 0;
|
||||
return AppPatchManifest.ResourceVersion;
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||
{
|
||||
YooLogger.Warning($"Editor play mode can not get bundle info.");
|
||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||
return bundleInfo;
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
return new BundleInfo(string.Empty);
|
||||
|
||||
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||
{
|
||||
string mainAssetPath = AppPatchManifest.TryGetBundleMainAssetPath(bundleName);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, mainAssetPath);
|
||||
return bundleInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
string IBundleServices.ConvertAddress(string address)
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
throw new Exception($"Editor play mode not support addressable.");
|
||||
return AppPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
return assetPath;
|
||||
return AppPatchManifest.GetBundleName(assetPath);
|
||||
}
|
||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||
{
|
||||
return new string[] { };
|
||||
return AppPatchManifest.GetAllDependencies(assetPath);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -309,9 +309,9 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
string IBundleServices.ConvertAddress(string address)
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return LocalPatchManifest.ConvertAddress(address);
|
||||
return LocalPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
|
||||
@@ -56,9 +56,9 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
string IBundleServices.ConvertAddress(string address)
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return AppPatchManifest.ConvertAddress(address);
|
||||
return AppPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetBundleName(string assetPath)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user