AutoRotate.cs 450 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using UnityEngine;
  3. public class AutoRotate : MonoBehaviour
  4. {
  5. private void Update()
  6. {
  7. Vector3 a = Vector3.one * this.Speed;
  8. if (!this.RotateOnX)
  9. {
  10. a.x = 0f;
  11. }
  12. if (!this.RotateOnY)
  13. {
  14. a.y = 0f;
  15. }
  16. if (!this.RotateOnZ)
  17. {
  18. a.z = 0f;
  19. }
  20. base.transform.Rotate(a * Time.deltaTime);
  21. }
  22. public float Speed = 5f;
  23. public bool RotateOnX = true;
  24. public bool RotateOnY = true;
  25. public bool RotateOnZ = true;
  26. }