就是让图片不断变大缩小,或者旋转。很简单的,使用DoTween来实现的。
/*--------------------------------------------------------------------
- Author Name: DXL
- Creation Time: 6/14/2019 10:52:17 AM
- File Describe: 一些图片的动作
- ------------------------------------------------------------------*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class IconEffect : MonoBehaviour
{
public enum IconEffType
{
Scale, //修改大小
Rotate, //旋转角度
}
public IconEffType type = IconEffType.Scale; //特效类型
public float actionTime = 1f; //特效时间
//如果类型是scale,则这个值是期望的大小,如果是rotate,则这个填写旋转的角度
public float targetValue; //目标值
void Start ()
{
Vector3 rot = transform.localRotation.eulerAngles;
switch (type)
{
case IconEffType.Scale:
{
transform.DOScale(targetValue, actionTime).SetLoops(-1, LoopType.Yoyo);
break;
}
case IconEffType.Rotate:
{
transform.DOLocalRotate(new Vector3(rot.x,rot.y, targetValue), actionTime).SetLoops(-1, LoopType.Restart);
break;
}
}
}
void OnDisable()
{
DOTween.Pause(transform);
}
void OnDestroy()
{
DOTween.Kill(transform);
}
}