- Home /
Question by
Jeff Ciaccio · Jul 01, 2010 at 02:25 AM ·
variableinstance
Creating fields/instance variables
Is the normal way to create fields by creating a script and attaching it to an object within a prefab?
var field1;
var field2; //both initialized when the obj is intantiated
var instID;
Comment
Best Answer
Answer by Tetrad · Jul 01, 2010 at 02:27 AM
It doesn't necessarily need to be in a prefab. You can just put it on an object in the scene. But yes.
Just make sure to specify your type, i.e.
var field1 : float; // or whatever
Your answer
![](https://koobas.hobune.stream/wayback/20220613063554im_/https://answers.unity.com/themes/thub/images/avi.jpg)