MenuManager.cs 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace TobyFredson
  5. {
  6. public class MenuManager : MonoBehaviour {
  7. // Changed to GameObject because only the game object of the menu needs to be accessed, you can
  8. // change this to any class that inherits MonoBehaviour
  9. public GameObject optionsMenu;
  10. public GameObject lights;
  11. public GameObject sun;
  12. // Update is called once per frame
  13. void Update ()
  14. {
  15. // Reverse the active state every time escape is pressed
  16. if (Input.GetKeyDown(KeyCode.H))
  17. {
  18. // Check whether it's active / inactive
  19. bool isActive = optionsMenu.activeSelf;
  20. optionsMenu.SetActive(!isActive);
  21. }
  22. if (Input.GetKeyDown(KeyCode.Alpha1))
  23. {
  24. bool isActive = lights.activeSelf;
  25. lights.SetActive(!isActive);
  26. }
  27. if (Input.GetKeyDown(KeyCode.Alpha2))
  28. {
  29. bool isActive = sun.activeSelf;
  30. sun.SetActive(!isActive);
  31. }
  32. }
  33. }
  34. }