SimpleRotate.cs 915 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using UnityEngine;
  3. namespace Xft
  4. {
  5. public class SimpleRotate : MonoBehaviour
  6. {
  7. private void Start()
  8. {
  9. this.OriAngleX = base.transform.rotation.x;
  10. this.OriAngleY = base.transform.rotation.y;
  11. this.OriAngleZ = base.transform.rotation.z;
  12. }
  13. private void Update()
  14. {
  15. if (this.RotateX)
  16. {
  17. this.OriAngleX += Time.deltaTime * this.RotateSpeed;
  18. }
  19. if (this.RotateY)
  20. {
  21. this.OriAngleY -= Time.deltaTime * this.RotateSpeed;
  22. }
  23. if (this.RotateZ)
  24. {
  25. this.OriAngleZ += Time.deltaTime * this.RotateSpeed;
  26. }
  27. base.transform.rotation = Quaternion.Euler(this.OriAngleX, this.OriAngleY, this.OriAngleZ);
  28. }
  29. protected float OriAngleX;
  30. protected float OriAngleY;
  31. protected float OriAngleZ;
  32. public float RotateSpeed = 20f;
  33. public bool RotateX = true;
  34. public bool RotateY;
  35. public bool RotateZ;
  36. }
  37. }