Hi there,
This may be a thread for the support subforum, but I made a shot here in the scripting subforum.
I currently got two JavaScript scripts in my project. One of them handles all the network communication and stores all the variables used (these are of course public variables), and the other script is simply a menu script that draws GUI layouts and handles menu navigation - and calls public functions on the network-script.
The problem lies within using a specific line of code. At the start of my script, in the Awake() function, I’ve used GetComponent for the network-script to access the menu-script, and vice versa. The variables to these are declared at the beginning of the script, outside any function (as in exposed variables).
The following code causes the problem; my program simply crashes when I try to run a test of it within the Unity Editor:
GUILayout.BeginVertical();
var userName : String; // Temp var
userName = GUILayout.TextField(userName, GUILayout.MinWidth(110));
GUILayout.EndVertical();
This code is of course embedded within a function and the function is being called perfectly. When I comment the above code out, the entire script is flawless and runs like it should. But when I uncomment it and try to use it, the program hangs for a few seconds after pressing “Play” and then Windows tells me the program encountered a problem, and then the Windows problem solver appears.
This has happened every time now, except when I do the following:
GUILayout.BeginVertical();
var userName : String; // Temp var
userName = GUILayout.TextField("", GUILayout.MinWidth(110));
GUILayout.EndVertical();
But then, of course, I can’t edit the textfield like this. It simply does not like the fact that I try to edit a variable within GUILayout.TextField().
Does anyone have a clue as to what may be crashing my editor?
Many thanks for any replies.