Unity_DoTween animation

using UnityEngine;
using DG.Tweening;//引入命名空间
public class DoTweenTest : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        // 世界坐标系位置
        transform.DOMove(new Vector3(20, 20, 29), 2f);
        // 本地坐标
        transform.DOLocalMove(new Vector3(20, 20, 29), 2f);
        // 某个轴的位置移动
        transform.DOLocalMoveX(20, 2f);
        transform.DOLocalMoveY(20, 2f);
        transform.DOLocalMoveZ(20, 2f);
        // 物体世界坐标旋转
        transform.DORotate(new Vector3(0, 20, 9), 2f);
        // 物体本地坐标旋转
        transform.DOLocalRotate(new Vector3(0, 20, 9), 2f);

        // 物体大小的缩放
        transform.DOScale(new Vector3(5, 5, 5), 2f);
        // 绕某个轴的缩放
        transform.DOScaleX(6, 2f);
        transform.DOScaleY(6, 2f);
        transform.DOScaleZ(6, 2f);

        // 物体的跳跃,目标位置,跳跃高度,跳跃次数,时间,
        transform.DOJump(new Vector3(60, 0, 0), 2, 5, 2f);
        transform.DOLocalJump(new Vector3(60, 0, 0), 2, 5, 2f);

        // 物体弹簧冲击,位置,时间,振幅,频率
        transform.DOPunchPosition(new Vector3(100, 0, 0), 3f, 10, 1);
        // 物体弹簧旋转
        transform.DOPunchRotation(new Vector3(100, 0, 0), 3f, 10, 1);
        // 物体弹簧缩放
        transform.DOPunchScale(new Vector3(100, 0, 0), 3f, 10, 1);

        // 旋转目标
        transform.DOLookAt(new Vector3(1, 0, 0), 2f);

        // 位置增量,位置叠加,X轴移动20,不是移动到20
        transform.DOBlendableMoveBy(new Vector3(20, 0, 0), 2f);
        transform.DOBlendableMoveBy(new Vector3(20, 0, 0), 2f);
        // 旋转角度增量
        transform.DOBlendableScaleBy(new Vector3(20, 0, 0), 2f);
        transform.DOBlendableScaleBy(new Vector3(20, 0, 0), 2f);
        // 旋转缩放增量
        transform.DOBlendableScaleBy(new Vector3(20, 0, 0), 2f);
        transform.DOBlendableScaleBy(new Vector3(20, 0, 0), 2f);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

 

Color transparency control, what changes is the Shader color

 Modify material type

 The color attribute of the shader becomes

 

Hang up the DoTweenTest script, color gradient

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;//引入命名空间
using UnityEngine.UI;

public class DoTweenTest : MonoBehaviour
{
    // 渐变的颜色
    public Gradient gradient;
    // Start is called before the first frame update
    void Start()
    {
        //修改材质颜色
        Material material = GetComponent<MeshRenderer>().material;
        material.DOColor(Color.red, 2f);
         修改材质类型之后需要手动指定材质
        //material.DOColor(Color.red, "_TintColor", 2f);

         对字体颜色进行修改
        //Text text = GetComponent<Text>();
        //text.DOColor(Color.red, 2f);

         修改透明度,shader类型必须修改为_TintColor
        //material.DOFade(0, "_TintColor", 2f);

        material.DOGradientColor(gradient, 2f);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

 Vibration effect performance

Object path animation

 You can also directly add DoTweenPath script editing

Press shift+ctrl to add points

Press shift+alt to delete points

 

 

Guess you like

Origin blog.csdn.net/qq_35647121/article/details/126923686