// Input void DrawInputSettings() { //var areaRect = GUILayoutUtility.GetLastRect(); //var width = areaRect.width; int width = 300; GUILayout.BeginVertical(); inputScrollPosition = GUILayout.BeginScrollView(inputScrollPosition); // Mouse GUILayout.BeginHorizontal(); GUILayout.Label("Mouse sensitivity", settingNameStyle, GUILayout.Width(width)); inputManager.mouseSensitivity = GUILayout.HorizontalSlider(inputManager.mouseSensitivity, 1.0f, 9.0f); GUILayout.EndHorizontal(); // Keybinds for (int i = 0; i < inputManager.controls.Length; i++) { var control = inputManager.controls[i]; if (!control.active) { continue; } GUILayout.BeginHorizontal(); // Name GUI.contentColor = Color.white; GUI.enabled = (captureControl == null || captureControl == control); GUILayout.Label(control.name, settingNameStyle, GUILayout.Width(width)); // Main key //GUI.enabled = (captureControl == null || (captureControl == control && captureAltKey == false)); if (control == captureControl && !captureAltKey) { GUI.contentColor = Color.red; } else { GUI.contentColor = Color.white; } if (GUIHelper.Button(control.keyCodeString, settingValueStyle, GUILayout.Width(width)) && captureControl == null && enableCapture) { Sounds.instance.buttonClick.Play(); captureControl = control; captureAltKey = false; lobbyChat.chatInputEnabled = false; } // Alt key //GUI.enabled = (captureControl == null || (captureControl == control && captureAltKey == true)); if (control == captureControl && captureAltKey) { GUI.contentColor = Color.red; } else { GUI.contentColor = Color.white; } if (GUIHelper.Button(control.altKeyCodeString, settingValueStyle, GUILayout.Width(width)) && captureControl == null && enableCapture) { Sounds.instance.buttonClick.Play(); captureControl = control; captureAltKey = true; lobbyChat.chatInputEnabled = false; } GUILayout.EndHorizontal(); } // Capture a key if (captureControl != null) { // Cancel capturing with escape if (Event.current.keyCode == KeyCode.Escape) { captureControl = null; lobbyChat.chatInputEnabled = true; // Erase keycode with backspace } else if (Event.current.keyCode == KeyCode.Backspace) { captureControl.Erase(captureAltKey); captureControl = null; lobbyChat.chatInputEnabled = true; // Overwrite key code with currently pressed key } else { lastKeyCaptured = captureControl.Capture(captureAltKey); if (lastKeyCaptured != KeyCode.None) { captureControl = null; enableCapture = false; modified = true; // To be safe Invoke("EnableCapture", 1.0f); } } if (Event.current.isKey) { Event.current.Use(); } } GUI.enabled = true; GUI.contentColor = Color.white; GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = modified; if (modified) { GUI.backgroundColor = Color.yellow; } else { GUI.backgroundColor = Color.white; } if (GUIHelper.Button("Save", GUILayout.Width(96))) { Sounds.instance.buttonClick.Play(); Lobby.RPC("ClientInputSettings", Lobby.lobby, Jboy.Json.WriteObject(new InputSettings(inputManager))); modified = false; } GUI.enabled = true; GUI.backgroundColor = Color.white; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); }