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.

70 lines
2.0 KiB

7 years ago
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Reflection;
  4. using DentedPixel;
  5. public class GeneralEasingTypes : MonoBehaviour {
  6. public float lineDrawScale = 10f;
  7. public AnimationCurve animationCurve;
  8. private string[] easeTypes = new string[]{
  9. "EaseLinear","EaseAnimationCurve","EaseSpring",
  10. "EaseInQuad","EaseOutQuad","EaseInOutQuad",
  11. "EaseInCubic","EaseOutCubic","EaseInOutCubic",
  12. "EaseInQuart","EaseOutQuart","EaseInOutQuart",
  13. "EaseInQuint","EaseOutQuint","EaseInOutQuint",
  14. "EaseInSine","EaseOutSine","EaseInOutSine",
  15. "EaseInExpo","EaseOutExpo","EaseInOutExpo",
  16. "EaseInCirc","EaseOutCirc","EaseInOutCirc",
  17. "EaseInBounce","EaseOutBounce","EaseInOutBounce",
  18. "EaseInBack","EaseOutBack","EaseInOutBack",
  19. "EaseInElastic","EaseOutElastic","EaseInOutElastic",
  20. "EasePunch","EaseShake",
  21. };
  22. void Start () {
  23. demoEaseTypes();
  24. }
  25. private void demoEaseTypes(){
  26. for(int i = 0; i < easeTypes.Length; i++){
  27. string easeName = easeTypes[i];
  28. Transform obj1 = GameObject.Find(easeName).transform.FindChild("Line");
  29. float obj1val = 0f;
  30. LTDescr lt = LeanTween.value( obj1.gameObject, 0f, 1f, 5f).setOnUpdate( (float val)=>{
  31. Vector3 vec = obj1.localPosition;
  32. vec.x = obj1val*lineDrawScale;
  33. vec.y = val*lineDrawScale;
  34. obj1.localPosition = vec;
  35. obj1val += Time.deltaTime/5f;
  36. if(obj1val>1f)
  37. obj1val = 0f;
  38. });
  39. if(easeName.IndexOf("AnimationCurve")>=0){
  40. lt.setEase(animationCurve);
  41. }else{
  42. MethodInfo theMethod = lt.GetType().GetMethod("set"+easeName);
  43. theMethod.Invoke(lt, null);
  44. }
  45. if(easeName.IndexOf("EasePunch")>=0){
  46. lt.setScale(1f);
  47. }
  48. }
  49. LeanTween.delayedCall(gameObject, 10f, resetLines);
  50. LeanTween.delayedCall(gameObject, 10.1f, demoEaseTypes);
  51. }
  52. private void resetLines(){
  53. for(int i = 0; i < easeTypes.Length; i++){
  54. Transform obj1 = GameObject.Find(easeTypes[i]).transform.FindChild("Line");
  55. obj1.localPosition = new Vector3(0f,0f,0f);
  56. }
  57. }
  58. }