RandomRotateOnStart.cs 560 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using UnityEngine;
  3. public class RandomRotateOnStart : BaseBehaviour
  4. {
  5. private void Start()
  6. {
  7. this.t = base.transform;
  8. this.t.Rotate(this.NormalizedRotateVector * (float)UnityEngine.Random.Range(0, 360));
  9. this.isInitialized = true;
  10. }
  11. private void OnEnable()
  12. {
  13. if (this.isInitialized)
  14. {
  15. this.t.Rotate(this.NormalizedRotateVector * (float)UnityEngine.Random.Range(0, 360));
  16. }
  17. }
  18. public Vector3 NormalizedRotateVector = new Vector3(0f, 1f, 0f);
  19. private Transform t;
  20. private bool isInitialized;
  21. }