You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

53 line
1.0KB

  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace coa4u
  5. {
  6. public class MethodHolder
  7. {
  8. protected Action method;
  9. protected string methodName;
  10. public MethodHolder()
  11. {
  12. }
  13. public MethodHolder(Action tgtMethod)
  14. {
  15. method = tgtMethod;
  16. methodName = tgtMethod.Method.Name;
  17. }
  18. public virtual void run(object param = null)
  19. {
  20. if (method != null)
  21. method.Invoke();
  22. }
  23. public string name
  24. {
  25. get
  26. {
  27. return methodName;
  28. }
  29. }
  30. }
  31. public class MethodHolder<T> : MethodHolder
  32. {
  33. protected Action<T> methodParam;
  34. public MethodHolder(Action<T> tgtMethod)
  35. {
  36. methodParam = tgtMethod;
  37. methodName = tgtMethod.Method.Name;
  38. }
  39. public override void run(object param)
  40. {
  41. if (methodParam != null)
  42. methodParam.Invoke((T)param);
  43. }
  44. }
  45. }