unity dotween 颜色大小位置透明度的改变

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

//点击按钮,UI动画
public class ColorMove : MonoBehaviour
{


    public Image ban;//图片
    private bool isTrue = true;//是否播放
    private Color yanse;//本身的颜色


    void Start()
    {
        Tweener tweener1 = ban.transform.DOLocalMove(new Vector3(-731, -387, 0), 2);//改变位置
        Tweener tweener2 = ban.transform.DOScale(0.1f, 2);//改变大小
        tweener1.SetAutoKill(false);//自动销毁为否
        tweener2.SetAutoKill(false);
        tweener1.Pause();//动画暂停
        tweener2.Pause();
        yanse = ban.color;
        print(yanse);
    }


    public void OnClick()
    {
        if (isTrue)
        {
            ban.transform.DOPlayForward();//向前
            isTrue = false;
            ban.DOColor(Color.red, 2);//颜色改变
            ban.DOFade(0, 2);//透明度改变


        }
        else
        {
            ban.transform.DOPlayBackwards();//向后
            ban.DOColor(yanse, 2);//回到本来颜色
            ban.DOFade(1, 2);//透明度改变
            isTrue = true;
        }
    }


}

你可能感兴趣的:(Dotween)