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;
}
}
}