2025-02-05 13:06:28 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
|
|
namespace YooAsset
|
|
|
|
|
{
|
2025-09-02 19:21:49 +08:00
|
|
|
|
public static class PackageInvokeBuilder
|
2025-02-05 13:06:28 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 调用Editro类来执行构建资源包任务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static PackageInvokeBuildResult InvokeBuilder(PackageInvokeBuildParam buildParam)
|
|
|
|
|
{
|
|
|
|
|
var assemblyName = buildParam.InvokeAssmeblyName;
|
|
|
|
|
var className = buildParam.InvokeClassFullName;
|
|
|
|
|
var methodName = buildParam.InvokeMethodName;
|
|
|
|
|
var classType = Assembly.Load(assemblyName).GetType(className);
|
|
|
|
|
return (PackageInvokeBuildResult)InvokePublicStaticMethod(classType, methodName, buildParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
namespace YooAsset
|
|
|
|
|
{
|
2025-09-02 19:21:49 +08:00
|
|
|
|
public static class PackageInvokeBuilder
|
2025-02-05 13:06:28 +08:00
|
|
|
|
{
|
|
|
|
|
public static PackageInvokeBuildResult InvokeBuilder(PackageInvokeBuildParam buildParam)
|
|
|
|
|
{
|
|
|
|
|
throw new System.Exception("Only support in unity editor platform !");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|