1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- using UnityEngine;
- namespace RenderHeads.Media.AVProVideo.Demos
- {
- [RequireComponent(typeof(Transform))]
- public class AutoRotate : MonoBehaviour
- {
- private void Awake()
- {
- this.Randomise();
- }
- private void Update()
- {
- base.transform.Rotate(this.x * Time.deltaTime, this.y * Time.deltaTime, this.z * Time.deltaTime);
- this._timer -= Time.deltaTime;
- if (this._timer <= 0f)
- {
- this.Randomise();
- }
- }
- private void Randomise()
- {
- float num = 32f;
- this.x = UnityEngine.Random.Range(-num, num);
- this.y = UnityEngine.Random.Range(-num, num);
- this.z = UnityEngine.Random.Range(-num, num);
- this._timer = UnityEngine.Random.Range(5f, 10f);
- }
- private float x;
- private float y;
- private float z;
- private float _timer;
- }
- }
|