- Home /
NullReference on textfield
Hello community,
I've encountered a very troublesome error recently, happens every time I edit a textfield... the textfield being in a window. Many people have this issue when not initializing the string for the textfield, mine is initialized... any ideas ?
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.GUI.DoTextField (Rect position, Int32 id, UnityEngine.GUIContent content, Boolean multiline, Int32 maxLength, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/GUI.cs:601)
UnityEngine.GUI.TextArea (Rect position, System.String text) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/GUI.cs:453)
RenameProjectPopUp.DrawChild () (at Assets/NewUI/menuAvril/RenameProjectPopUp.cs:15)
IRCPopUp.doWindow (Int32 WindowID) (at Assets/NewUI/IRCPopUp.cs:253)
UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/GUI.cs:1283)
A very simple code wouldn't work neither.
string bob = "";
void OnGUI() { bob = GUI.TextField(new Rect(0, 0, 100, 30), bob); }
That's why I didn't post code ...
I pasted the code provided above into a cs file in my project and it runs fine, no errors. Just draws a textfield in the upper left corner. Perhaps the problem is else where.
I did the same and it worked on another project, what I mean is that there is a problem maybe with the default skin or something ? If I give another default value to the string it writes that value and I still can't change it. Still no ideas ?
Answer by BimSekai · Aug 27, 2013 at 07:09 AM
Okay, found it. I somehow modified the unity's default skin, and it had a problem with the font, causing the exception.