Enter and Return in TextField in Mac Not Working

I created a game which teaches the player how to navigate within the Linux file structure. The game works flawlessly on Windows with the Unity Web Player. (Issue #1) However, on a Mac, the commands are never “entered”, i.e. although the player can insert a carriage return, it never carries out the command or even prints it in the history console. (Issue #2) Additionally, if anyone can offer advice on how to get this game working for Linux natively (WINE is not the best option) and I’ve done a “universal 32-64” build for Linux which did not work. The students use CentOS as their Linux distro.

Play the game here: File Fishing

function OnGUI () {

GUI.skin = linuxSkin;

GUI.Label (prefaceRect, preface, "command");
GUI.SetNextControlName("CommandLine");
command = GUI.TextField (commandLineRect, command, 30, "command");
GUI.FocusControl("CommandLine");
//create console area
GUI.SetNextControlName("History");
	scrollPosition = GUI.BeginScrollView (historyLogRect, scrollPosition, scrollViewRect);
	scrollViewRect.height = 17.5 * linesFed;
	GUI.Box(scrollBounds, "");
	
	if (scrollViewRect.Contains(Event.current.mousePosition))
	{
	   if (Event.current.type == EventType.MouseDrag)
	   {
	      scrollPosition.y = Event.current.mousePosition.y;
	     // Event.current.Use();
	   }
	}
	else {
		scrollPosition.y = scrollViewRect.height;
		}
	
	GUI.Label(scrollViewRect, history, "command");
	
	previousCommand = command;
	GUI.EndScrollView ();
		
if (Event.current.type == EventType.KeyUp && (Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter || Event.current.character == '

'))
{
scrollPosition.y = scrollViewRect.height;
invalidCommand = false;
subCommand = null;
iter = 0;
commandBrokenDown = false;
i = 0;
for (j=0; j<increment.Length; j++)
{
increment[j]=null;
}
if (pwd)
{
pwd = false;
}
history += command;
linesFed++;

	BreakDownCommand();
	if (command.StartsWith("cd") && !invalidCommand)
	{
		CarryOutCommand();
	}
	
	command = "";
	

	if (invalidCommand)
	{
		history += "No such directory found.

";
linesFed++;
audio.PlayOneShot(errorSound);
}

	if (remindOfCase)
	{
		history += "Reminder: Linux is case sensitive.

";
linesFed += 2;
audio.PlayOneShot(errorSound);
remindOfCase = false;
}

}


}

I have a similar problem with my Linux version.
When I try to input the enter key it is printing a weird symbol (like ¬)
and is not being ‘considered’ in the following if statement on the Update function:

void Update(){
    if( Input.GetKeyDown( KeyCode.KeypadEnter ) || Input.GetKeyDown( KeyCode.Return ) )
        // do something
}

However, in the Windows version it works just fine.

Furthermore, the Linux version have at least another two problems I could identify - when using Ubuntu 14 and compiling with Unity3D 4.5.3f3:

  • controllers focus problem: In the Windows version, when I select a textfield and type ‘w’ for example, only the textfield is updated accordingly; in the other hand, in the linux version, besides updating the textfield my avatar also moves;

  • numeric keypad problem: In Linux version when I type a key in the numeric keypad nothing is inserted in a textfield and incorrect characters are inserted in a password field (because I tested the ‘super secret’ password “123456” using the numeric keypad and I got invalid password, and when I type it on the other numeric keys (bellow F1, F2, …) it worked just fine. And again, in Windows version this problem does not occurs.