EditorSimulateModeHelper.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #if UNITY_EDITOR
  2. using System.Reflection;
  3. namespace YooAsset
  4. {
  5. public static class EditorSimulateModeHelper
  6. {
  7. private static System.Type _classType;
  8. /// <summary>
  9. /// 编辑器下模拟构建清单
  10. /// </summary>
  11. public static string SimulateBuild(string packageName)
  12. {
  13. if (_classType == null)
  14. _classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleSimulateBuilder");
  15. string manifestFilePath = (string)InvokePublicStaticMethod(_classType, "SimulateBuild", packageName);
  16. return manifestFilePath;
  17. }
  18. private static object InvokePublicStaticMethod(System.Type type, string method, params object[] parameters)
  19. {
  20. var methodInfo = type.GetMethod(method, BindingFlags.Public | BindingFlags.Static);
  21. if (methodInfo == null)
  22. {
  23. UnityEngine.Debug.LogError($"{type.FullName} not found method : {method}");
  24. return null;
  25. }
  26. return methodInfo.Invoke(null, parameters);
  27. }
  28. }
  29. }
  30. #else
  31. namespace YooAsset
  32. {
  33. public static class EditorSimulateModeHelper
  34. {
  35. /// <summary>
  36. /// 编辑器下模拟构建清单
  37. /// </summary>
  38. public static string SimulateBuild(string packageName) { throw new System.Exception("Only support in unity editor !"); }
  39. }
  40. }
  41. #endif