Unity的DoTween插件缓动动画效果

本文分享了一个Unity小Demo,用于展示并记录DoTween动画中各种Ease类型的效果,通过持续1秒的位移动画,直观对比不同缓动曲线的表现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

很久不用了,为了防止忘记DoTween设动画节奏的时候用什么类型的Ease,所以我专门写了一个小demo,记录比较DoTween的各种动画类型。

动画执行测试代码:

using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class Main : MonoBehaviour
{
 
    //public Dropdown dropDownItem;
    public Text txt_title;
    public GridLayoutGroup gridLayoutGroup;
    public RectTransform rect_item_0;
 
    List<string> showNames = new List<string>();
    List<int> valueList = new List<int>();
 
    // Use this for initialization
    void Start()
    {
        rect_item_0.gameObject.SetActive(false);
        txt_title.text = "各种欢动曲线下的位移动画(以持续1s的位移动画为例)";
        int index = 1;
        foreach (var value in Enum.GetValues(typeof(Ease)))
        {
            //从 330 到 -360
            RectTransform rect = GameObject.Instantiate(rect_item_0).GetComponent<RectTransform>();
            rect.gameObject.SetActive(true);
            rect.localScale = Vector3.one;
            rect.SetParent(gridLayoutGroup.transform, false);
            rect.Find("txt_animation_type").GetComponent<Text>().text = "(" + index + ") " + value.ToString();
 
            RectTransform rectDrop = rect.Find("img_drop").GetComponent<RectTransform>();
            rectDrop.anchoredPosition = new Vector2(0, 140);
            var tMove = rectDrop.DOAnchorPos(new Vector2(0, -170), duration: 1f, snapping: false);
            tMove.SetEase((Ease)(value));
            tMove.SetLoops(-1);
            index++;
        }
    }
}
所有的缓动取消效果:


--------------------- 
作者:Stephanie_1 
来源:优快云 
原文:https://blog.youkuaiyun.com/Stephanie_1/article/details/82953857 
版权声明:本文为博主原创文章,转载请附上博文链接!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值