Untitled

 avatar
unknown
plain_text
5 months ago
559 B
2
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