Seven is the number.
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.

38 lines
833 B

4 years ago
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnityEngine.UI;
  4. public class Skybox_rotator : MonoBehaviour
  5. {
  6. public Text skyboxNameText;
  7. public List<Material> skyboxes;
  8. private int currentSkybox = 0;
  9. void Start()
  10. {
  11. SetSkybox();
  12. }
  13. void Update ()
  14. {
  15. if (Input.GetMouseButtonDown(0))
  16. {
  17. // increment the skybox
  18. currentSkybox++;
  19. if (currentSkybox >= skyboxes.Count)
  20. {
  21. // loop round to the first skybox if we have reached the last skybox
  22. currentSkybox = 0;
  23. }
  24. SetSkybox();
  25. }
  26. }
  27. void SetSkybox()
  28. {
  29. // set the skybox
  30. RenderSettings.skybox = skyboxes[currentSkybox];
  31. skyboxNameText.text = skyboxes[currentSkybox].name;
  32. }
  33. }