unity what does a singleton mean code example
Example: singleton unity
public class Example
{
public static Example Instance{get; private set;}
void awake()
{
if(Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
} else
{
Destroy(gameObject);
}
}
}