描述:想要的达到的效果,用DOTween去实现,一张图片旋转后消失。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class ButtonShaderAnimator : MonoBehaviour {
private Image starImg;
private float rote;
private float colors = 1;
void Start () {
starImg = GameObject.Find("Star").GetComponent<Image>();
starImg.gameObject.SetActive(false);
Invoke("StarRote", 2f);
}
private void StarRote()
{
Tween t1;
Tween t2;
starImg.gameObject.SetActive(true);
t1 = DOTween.To(() => rote, x => rote = x, -360f, 1f).SetEase(Ease.OutQuad).OnUpdate(() =>
{
starImg.GetComponent<RectTransform>().GetComponent<RectTransform>().eulerAngles = new Vector3(0, 0, rote);
});
t2 = DOTween.To(() => colors, x =>