微信登录

插件 - DOTween - 变量进行动画

作用:通过变量Vector改变

  1. DOTween.To(() => 啥, x => = x, 目标值,变化时间秒);
  2. DOTween.To(() => 啥, x => = x, Vector3(10,10,10), 2);
  3. DOTween.To(() => , x => = x, Vector3(10,10,10), 2);

代码

  1. using UnityEngine;
  2. using System.Collections;
  3. using DG.Tweening;//DOTween类
  4. public class GetStart : MonoBehaviour {
  5. public Vector3 myValue = new Vector3(0,0,0);//位置
  6. // Use this for initialization
  7. void Start () {
  8. //对变量做一个动画 (通过插值的方式去修改一个值的变化)
  9. //(原来值(返回x),(接收x)赋值,目标值,变化时间秒)
  10. DOTween.To(() => myValue2, x => myValue2 = x, 10, 2);
  11. }
  12. // Update is called once per frame
  13. void Update () {
  14. }
  15. }
  1. using UnityEngine;
  2. using System.Collections;
  3. using DG.Tweening;
  4. public class GetStart : MonoBehaviour {
  5. public Vector3 myValue = new Vector3(0,0,0);
  6. public Transform cubeTransform;
  7. public RectTransform taskPanelTransform;
  8. public float myValue2 = 0;
  9. // Use this for initialization
  10. void Start () {
  11. //对变量做一个动画 (通过插值的方式去修改一个值的变化)
  12. //(,秒)
  13. DOTween.To(() => myValue2, x => myValue2 = x, 10, 2);
  14. }
  15. // Update is called once per frame
  16. void Update () {
  17. //cubeTransform.position = myValue;
  18. //taskPanelTransform.position = myValue;
  19. taskPanelTransform.localPosition = myValue;
  20. }
  21. }