DemoInstructions.cs 856 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace HQFPSWeapons.Demo
  4. {
  5. public class DemoInstructions : MonoBehaviour
  6. {
  7. [SerializeField]
  8. private bool m_InstructionsEnabledOnStart = false;
  9. [Space(3f)]
  10. [SerializeField]
  11. private Text m_MessageToggleText = null;
  12. [SerializeField]
  13. private GameObject m_InstructionsObject = null;
  14. private bool m_InstructionsEnabled;
  15. private void Awake()
  16. {
  17. m_InstructionsEnabled = m_InstructionsEnabledOnStart;
  18. Refresh();
  19. }
  20. private void Update()
  21. {
  22. if(Input.GetKeyDown(KeyCode.F12))
  23. {
  24. m_InstructionsEnabled = !m_InstructionsEnabled;
  25. Refresh();
  26. }
  27. }
  28. private void Refresh()
  29. {
  30. m_InstructionsObject.gameObject.SetActive(m_InstructionsEnabled);
  31. m_MessageToggleText.text = "Press F12 to " + (m_InstructionsEnabled ? "hide" : "show") + " the instructions.";
  32. }
  33. }
  34. }