Untitled
unknown
plain_text
a year ago
559 B
3
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PersistentObject : MonoBehaviour
{
private static PersistentObject instance;
void Awake()
{
// Asegura que solo exista una instancia del objeto
if (instance != null)
{
Destroy(gameObject); // Destruye duplicados en caso de recargar la escena
return;
}
instance = this;
DontDestroyOnLoad(gameObject); // Hace que el objeto no se destruya entre escenas
}
}
Editor is loading...
Leave a Comment