Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
405 B
4
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Singleton : MonoBehaviour
{
    public static Singleton instance;

    void Awake()
    {
        if (instance != null && instance != this){
            Destroy(gameObject);
        }
        else{
            instance = this;
            DontDestroyOnLoad(gameObject);     
        }
    }
}