AutoRotate.cs 790 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using UnityEngine;
  3. namespace RenderHeads.Media.AVProVideo.Demos
  4. {
  5. [RequireComponent(typeof(Transform))]
  6. public class AutoRotate : MonoBehaviour
  7. {
  8. private void Awake()
  9. {
  10. this.Randomise();
  11. }
  12. private void Update()
  13. {
  14. base.transform.Rotate(this.x * Time.deltaTime, this.y * Time.deltaTime, this.z * Time.deltaTime);
  15. this._timer -= Time.deltaTime;
  16. if (this._timer <= 0f)
  17. {
  18. this.Randomise();
  19. }
  20. }
  21. private void Randomise()
  22. {
  23. float num = 32f;
  24. this.x = UnityEngine.Random.Range(-num, num);
  25. this.y = UnityEngine.Random.Range(-num, num);
  26. this.z = UnityEngine.Random.Range(-num, num);
  27. this._timer = UnityEngine.Random.Range(5f, 10f);
  28. }
  29. private float x;
  30. private float y;
  31. private float z;
  32. private float _timer;
  33. }
  34. }