Bug regarding GUI.TextField (in Unity itself so I can't fix that)

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.TextEditor.ClampPos () (at C:/BuildAgent/work/812c4f5049264fad/Runtime/Export/TextEditor.cs:1184)
UnityEngine.GUI.DoTextField (Rect position, Int32 id, UnityEngine.GUIContent content, Boolean multiline, Int32 maxLength, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/GUI.cs:398)
UnityEngine.GUI.TextField (Rect position, System.String text) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/GUI.cs:308)
GameGUI.drawWorldToolbox () (at Assets/code/gui/GameGUI.cs:63)
GameGUI.OnGUI () (at Assets/code/gui/GameGUI.cs:19)
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.TextEditor.ClampPos () (at C:/BuildAgent/work/812c4f5049264fad/Runtime/Export/TextEditor.cs:1184)
UnityEngine.GUI.DoTextField (Rect position, Int32 id, UnityEngine.GUIContent content, Boolean multiline, Int32 maxLength, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/GUI.cs:398)
UnityEngine.GUI.TextField (Rect position, System.String text) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/GUI.cs:308)
GameGUI.drawWorldToolbox () (at Assets/code/gui/GameGUI.cs:63)
GameGUI.OnGUI () (at Assets/code/gui/GameGUI.cs:19)

It seems to be in Unity engine itself, so I can’t fix that.

Erroneous line in my code:

GameData.worldName = GUI.TextField(new Rect(128,55+15,(((Screen.width/3)*2)-32),24),GameData.worldName);

but it isn’t it.

Some explanation: GameData is a Static class that I use to transport data between scenes and different objects (full of static fields).

Thought that setting it directly may be problem, so made workaround by using something like this:

string tempname = GameData.worldName;
tempname = GUI.TextField(new Rect(128,55+15,(((Screen.width/3)*2)-32),24),tempname);
GameData.worldName = tempname;

Still, same error, at TextField line.

Next thing I did was to remove all funny calculation from new Rect(). My code looked now like this:

string tempname = GameData.worldName;
tempname = GUI.TextField(new Rect(128,55+15,200,24),tempname);
GameData.worldName = tempname;

Still, no dice. Any help? Hotfix maybe?

//edit: Was able to fix issue on my part by declaring worldName as

public static string worldName="";

instead of

public static string worldName;

Still, underlying issue of not dealing with null strings properly (i.e. changing string to empty one if null) should be fixed.

yep, seems like Unity 4.3.3’s GUI.TextField still can’t deal with null strings, though i think it should, or at least give a little more verbose error.