Advertisement
npgdev

Tweening

Dec 3rd, 2020
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1.  
  2. public class Breather : MonoBehaviour
  3. {
  4.     private void Awake()
  5.     {
  6.         Color color = Color.white;
  7.         color.a = 0;
  8.         GetComponent<Image>().DOColor(color, 1).SetLoops(-1, LoopType.Yoyo).Play();
  9.     }
  10. }
  11.  
  12.  
  13. public class Rotator : MonoBehaviour
  14. {
  15.     Tween rotator;
  16.  
  17.     private void Awake()
  18.     {
  19.         rotator = transform.DORotate(new Vector3(0, 180, 0), 2).SetLoops(-1, LoopType.Restart);
  20.     }
  21.  
  22.     private void OnMouseEnter()
  23.     {
  24.         rotator.Play();
  25.     }
  26. }
  27.  
  28.  
  29. public class Scaler : MonoBehaviour
  30. {
  31.     private Tween scaleTween;
  32.  
  33.     private void Awake()
  34.     {
  35.         scaleTween = transform.DOScale(1.5f, 1).SetLoops(-1, LoopType.Yoyo);
  36.     }
  37.  
  38.     public void Scale()
  39.     {
  40.         scaleTween.Play();
  41.     }
  42. }
  43.  
  44.  
  45.  
  46. public class Mover : MonoBehaviour
  47. {
  48.     public Vector3 offset;
  49.     public Vector3 destination;
  50.     public Transform waypoint;
  51.  
  52.     private void Awake()
  53.     {
  54.         Vector3 movementDestination = transform.position + offset;
  55.         transform.DOMove(movementDestination, 3).Play().onComplete += OnMoveCompleted;
  56.     }
  57.  
  58.     private void OnMoveCompleted()
  59.     {
  60.         Debug.Log("Completed Movement!");
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement