- Home /
Unity is automatically instantiating variables
I have a list of Character instances and a 'selectedChar' variable that I set to null if no one is selected, but sometimes Unity decides to un-null it by creating an empty Character instance for it. I've run into this problem before where I would look at an object in the inspector and its variables would be auto-instantiated, so I fixed that by keeping the inspector blank at runtime. This time though, it does it regardless. Has anyone run into this problem before?
Answer by Fattie · Nov 09, 2012 at 07:18 PM
i don't really know what you're referring to, but it's possible the magic NonSerialized directive might help you.
@System.NonSerialized
var thisProjectileHitType:int;
Your answer
![](https://koobas.hobune.stream/wayback/20220613083620im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Setting the variable on a GameObject to be instantiated (not yet existent) cs and js 2 Answers
Create plane from 2 Vectors of a symmetry line segment 1 Answer
Adding Instantiated Objects to ArrayList but it returns null C# 3 Answers
why cant I place the building prefab even though I have the correct amount of money? 3 Answers