Hello!
I have a problem. Here is some code samples:
public static Inventory instance { get; set; }
private void Awake()
{
if (instance == null)
{
instance = this;
}
else
{
DestroyObject(gameObject);
}
DontDestroyOnLoad(this);
}
public static Inventory instance { get; set; }
private void Awake()
{
if (instance == null)
{
instance = this;
}
else
{
Destroy(gameObject);
}
DontDestroyOnLoad(this);
}
One of these codes is working, and the other is not. I do not know what the problem is and I want to know. The official guide says that you need to use the Destroy method but it does not work for me. I use the DestroyObject method instead Destroy and it's work fine. Who can explain why this happens?
↧