You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
798 B

  1. using UnityEngine;
  2. using System.Collections;
  3. public class Rotator : MonoBehaviour
  4. {
  5. public float SpinSpeed = 1.0f;
  6. public Vector3 Axis =new Vector3(0, 1, 0);
  7. //float X, Y, Z;
  8. [SerializeField]
  9. Material Skybox;
  10. public bool rotateSky = false;
  11. float time;
  12. void Start()
  13. {
  14. // X = transform.eulerAngles.x;
  15. // Y = transform.eulerAngles.y;
  16. // Z = transform.eulerAngles.z;
  17. }
  18. void FixedUpdate()
  19. {
  20. time += Time.deltaTime;
  21. //transform.eulerAngles = new Vector3(X + time * SpinSpeed * Axis.x, Y + time * SpinSpeed* Axis.y, Z + time * SpinSpeed * Axis.z);
  22. transform.Rotate(Axis, SpinSpeed, Space.World);
  23. if (rotateSky && Skybox)
  24. Skybox.SetFloat("_Rotation", -transform.eulerAngles.y);
  25. }
  26. }