got a bit of a weird error, hopefully someone here can help.
So I have created a custom class (does not derive from Monobehavior).
Then I have a variable for the class, in the Start() method I set it to 'null', first time I play it in editor, everything is fine, (pickups/weapon switching etc..), but then when I play it again after a while, the variable is not null, even though I set it to null in Start().
Here's the code to make it easier:
[System.Serializable]
public class Weapon
{
public string weaponName;
}
public class PlayerFPS : MonoBehaviour
{
public Weapon secondary;
void Start(){
secondary = null;
print(secondary == null); //this returns True the first time I play, but False after
}
}
It seems that for some reason after playing in the editor, the variable stops setting to 'null'.
I do a lot of Instantiating and Destroying, so perhaps, the issue is somehow related to Garbage Collector or Cache?
Thanks in advance!