TextField

Why do textField not like private vars? They’ve been returning null reference exceptions for me.

This below example just shows the two lines. In my script the var is outside the function as should be and the textField is in the Gui function as should be lol.

Work around : I’m using a public var with @HideInInspector

private var setName : String; // The Data Set name.

setName = GUI.TextField (Rect (205,50,180,25), setName, 12);

I could be incorrect, but I think for it to be private you have to define the “setName” variable.

So:

private var setName:String = " "; //The space is needed. Or some random text.

setName = GUI.TextField(Rect(205,50,180,25), setName, 12);

TY for the reply. Your probably right. I always though the default was “”/null, so I wonder why the compiler needs to be told that lol.