what is a singleton code example
Example: singelton code
using UnityEngine;
public class SingeltonObject : MonoBehaviour
{
void Awake()
{
SetUpSingelton();
}
private void SetUpSingelton()
{
if (FindObjectsOfType(GetType()).Length > 1)
{
Destroy(gameObject);
}
else
{
DontDestroyOnLoad(gameObject);
}
}
}