1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.InputSystem;
- namespace Unity.RenderStreaming.Samples
- {
- internal class BackButton : MonoBehaviour
- {
- [SerializeField]
- GameObject m_BackButton;
- public GameObject backButton
- {
- get => m_BackButton;
- set => m_BackButton = value;
- }
- void Start()
- {
- if (Application.CanStreamedLevelBeLoaded("Menu"))
- {
- m_BackButton.SetActive(true);
- }
- }
- void Update()
- {
- if (Keyboard.current != null && Keyboard.current[Key.Escape].wasPressedThisFrame)
- {
- BackButtonPressed();
- }
- }
- public void BackButtonPressed()
- {
- if (Application.CanStreamedLevelBeLoaded("Menu"))
- {
- SceneManager.LoadScene("Menu", LoadSceneMode.Single);
- }
- }
- }
- }
|