void OnGUI() { if (this.client.SessionId == 0) { return; } if (Event.current.isKey) { CubeController.CommandId commandId = 0; switch (Event.current.keyCode) { case KeyCode.UpArrow: commandId = CubeController.CommandId.Forward; break; case KeyCode.DownArrow: commandId = CubeController.CommandId.Back; break; case KeyCode.LeftArrow: commandId = CubeController.CommandId.Left; break; case KeyCode.RightArrow: commandId = CubeController.CommandId.Right; break; default: break; } if (commandId != 0) { var command = new Command((uint)commandId, this.client.SessionId); this.client.SendCommand(this.sessionManager.CurrentTicks + 1, command); } } }
void OnGUI() { if (Event.current.isKey) { CubeController.CommandId commandId = 0; switch (Event.current.keyCode) { case KeyCode.UpArrow: commandId = CubeController.CommandId.Forward; break; case KeyCode.DownArrow: commandId = CubeController.CommandId.Back; break; case KeyCode.LeftArrow: commandId = CubeController.CommandId.Left; break; case KeyCode.RightArrow: commandId = CubeController.CommandId.Right; break; default: break; } if (commandId != 0) { var command = new Command((uint)commandId, 1); this.sessionManager.SendCommand(command); //Debug.Log(string.Format("NewCommand: {0}", commandId)); } } }