24 lines
		
	
	
		
			604 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			604 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using UnityEngine;
 | |
| using UnityEngine.SceneManagement;
 | |
| 
 | |
| public class PersistentSceneManager : MonoBehaviour
 | |
| {
 | |
|     private static bool isInitialized = false;
 | |
| 
 | |
|     private void Awake()
 | |
|     {
 | |
|         if (!isInitialized)
 | |
|         {
 | |
|             DontDestroyOnLoad(gameObject); // Previene la destrucción de este objeto al cambiar de escena
 | |
|             isInitialized = true;
 | |
| 
 | |
|             // Cargar la escena principal en modo aditivo
 | |
|             SceneManager.LoadScene("MainScreen", LoadSceneMode.Additive);
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             Destroy(gameObject); // Evitar duplicados
 | |
|         }
 | |
|     }
 | |
| }
 | 
