导入DoTween Pro 插件后,在物体身上添加DOTweenAnimation组件,实现物体360度匀速自转。可以参考下图:
不使用插件的代码如下:
using UnityEngine;
using System.Collections;
public class RotationController : MonoBehaviour
{
public float speedX = 20f;
public float speedY = 40f;
public float speedZ = 80f;
private Transform tr;
void Awake()
{
tr = GetComponent<Transform>();
}
void Update()
{
tr.Rotate(speedX * Time.deltaTime, speedY * Time.deltaTime, speedZ * Time.deltaTime);
}
}