InvokeOnHotReload.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Reflection;
  3. namespace SingularityGroup.HotReload {
  4. /// <summary>
  5. /// Methods with this attribute will get invoked after a hot reload
  6. /// </summary>
  7. /// <remarks>
  8. /// The method with this attribute needs to have no parameters.
  9. /// Further more it needs to either be static or and instance method inside a <see cref="UnityEngine.MonoBehaviour"/>.
  10. /// For the latter case the method of all instances of the <see cref="UnityEngine.MonoBehaviour"/> will be called.
  11. /// In case the method has a return value it will be ignored.
  12. /// </remarks>
  13. [AttributeUsage(AttributeTargets.Method)]
  14. public class InvokeOnHotReload : Attribute {
  15. }
  16. public class MethodPatch {
  17. // Compiled by the Unity Editor. Null for newly added methods.
  18. public MethodBase originalMethod;
  19. // Method before Hot Reload applied it's patch. Null for newly added methods.
  20. public MethodBase previousMethod;
  21. // Method generated by Hot Reload.
  22. public MethodBase newMethod;
  23. public MethodPatch(MethodBase originalMethod, MethodBase previousMethod, MethodBase newMethod) {
  24. this.originalMethod = originalMethod;
  25. this.previousMethod = previousMethod;
  26. this.newMethod = newMethod;
  27. }
  28. }
  29. }