22 lines
608 B
C#
22 lines
608 B
C#
using UnityEngine;
|
|
|
|
[ExecuteAlways] // <-- this is the key
|
|
public class AxisRotate : MonoBehaviour
|
|
{
|
|
[Header("Rotation Speed (degrees per second)")]
|
|
public float xSpeed = 0f;
|
|
public float ySpeed = 0f;
|
|
public float zSpeed = 0f;
|
|
|
|
[Header("Space")]
|
|
public Space rotationSpace = Space.Self;
|
|
|
|
void Update()
|
|
{
|
|
// Use different delta time depending on mode
|
|
float delta = Application.isPlaying ? Time.deltaTime : Time.unscaledDeltaTime;
|
|
|
|
Vector3 rotation = new Vector3(xSpeed, ySpeed, zSpeed);
|
|
transform.Rotate(rotation * delta, rotationSpace);
|
|
}
|
|
} |