void Awake()
 {
     if (Time.timeScale <= 0)
     {
         Time.timeScale = 1;
     }
     //GetPlayerConfig = GetComponentInChildren<PlayerConfig>();
     GetPlayer = FindObjectOfType <Player>();
     playerUI  = FindObjectOfType <ID_PlayerUI>();
 }
示例#2
0
 private void OnEnable()
 {
     if (SceneManager.GetActiveScene().name != "MainMenu")
     {
         if (instance != null && instance != this)
         {
             Destroy(this);
             return;
         }
         else
         {
             instance = this;
             DontDestroyOnLoad(this);
         }
     }
 }
    // called second
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        Debug.Log("OnSceneLoaded: " + scene.name);

        if (scene.name != "MainMenu")
        {
            GetPlayer = FindObjectOfType <Player>();
            playerUI  = FindObjectOfType <ID_PlayerUI>();
            if (GetPlayer && playerUI)
            {
                Debug.Log("Player and HUD found!");
            }
            // GetPlayerConfig.gameObject.SetActive(false);
        }
        else
        {
            if (GetPlayer && playerUI)
            {
                Destroy(GetPlayer.gameObject);
                Destroy(playerUI.gameObject);
                Debug.Log("Player and HUD removed!");
            }
        }
    }