• ReturnToMainMenu.cs
  • /
  • /
  • /
  • /
  • /
1 using System;
2 using
UnityEngine;
3 using
UnityEngine.SceneManagement;
4
5 public
class ReturnToMainMenu : MonoBehaviour
6 {
7     
private bool m_Levelloaded;
8
9
10     
public void Start()
11     {
12         DontDestroyOnLoad(
this);
13     }
14
15
16     
private void OnLevelWasLoaded(int level)
17     {
18         m_Levelloaded =
true;
19     }
20
21
22     
private void Update()
23     {
24         
if (m_Levelloaded)
25         {
26             Canvas component = gameObject.GetComponent<Canvas>();
27             component.enabled =
false;
28             component.enabled =
true;
29             m_Levelloaded =
false;
30         }
31     }
32
33
34     
public void GoBackToMainMenu()
35     {
36         Debug.Log(
"going back to main menu");
37         SceneManager.LoadScene(
"MainMenu");
38     }
39 }


Gõ tìm kiếm nhanh...