instantiate a singleton unity code example
Example: how to make a singleton in unity
void Awake()
{
if (instance == null)
instance = this;
else if (instance != this)
Destroy(gameObject);
}
void Awake()
{
if (instance == null)
instance = this;
else if (instance != this)
Destroy(gameObject);
}