EditorSimulateModeHelper.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #if UNITY_EDITOR
  2. using System.Reflection;
  3. namespace YooAsset
  4. {
  5. internal static class EditorSimulateModeHelper
  6. {
  7. private static System.Type _classType;
  8. public static string SimulateBuild()
  9. {
  10. _classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleSimulateBuilder");
  11. InvokePublicStaticMethod(_classType, "SimulateBuild");
  12. return GetPatchManifestFilePath();
  13. }
  14. private static string GetPatchManifestFilePath()
  15. {
  16. return (string)InvokePublicStaticMethod(_classType, "GetPatchManifestPath");
  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. internal static class EditorSimulateModeHelper
  32. {
  33. public static string SimulateBuild() { throw new System.Exception("Only support in unity editor !"); }
  34. }
  35. #endif