CustomTweenEX.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using Fort23.Core;
  3. using UnityEngine;
  4. namespace Utility.CTween
  5. {
  6. public static class CustomTweenEX
  7. {
  8. public enum CustomAnimationCurve
  9. {
  10. Line,
  11. InExpo
  12. }
  13. public static T SetEase<T>(this T t, CustomAnimationCurve ease) where T : CustomTweener
  14. {
  15. switch (ease)
  16. {
  17. case CustomAnimationCurve.Line:
  18. t.AnimationCurve = CustomTweenManager.AnimationCurveLibrary.Line;
  19. break;
  20. case CustomAnimationCurve.InExpo:
  21. t.AnimationCurve = CustomTweenManager.AnimationCurveLibrary.InExpo;
  22. break;
  23. }
  24. return t;
  25. }
  26. public static T OnComplete<T>(this T t, Action action) where T : CustomTweener
  27. {
  28. t.OnCompleteAction = action;
  29. return t;
  30. }
  31. public static T SetLoop<T>(this T t, bool isLoop) where T : CustomTweener
  32. {
  33. t.IsLoop = isLoop;
  34. return t;
  35. }
  36. /// <summary>
  37. /// 注册变量改变事件
  38. /// </summary>
  39. /// <param name="t"></param>
  40. /// <param name="action"></param>
  41. /// <typeparam name="T"></typeparam>
  42. /// <returns></returns>
  43. public static T RegValueChangeAction<T>(this T t, Action action) where T : CustomTweener
  44. {
  45. action.Invoke();
  46. return t;
  47. }
  48. public static T OnUpdate<T>(this T t, Action action) where T : CustomTweener
  49. {
  50. t.OnUpdateAction += action;
  51. return t;
  52. }
  53. public static T OnUpdate<T>(this T t, Action<object> action) where T : CustomTweener
  54. {
  55. t.OnUpdateAndValueAction += action;
  56. return t;
  57. }
  58. }
  59. }