Advertisement
Deozaan

cInput old GUI code

Jun 10th, 2013
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.48 KB | None | 0 0
  1. #region OnGUI
  2. void OnGUI() {
  3.     if (_showMenu) {
  4.         GUI.skin = cSkin;
  5.         int _amnt = (Mathf.Clamp(_inputLength, 2, 10)) * 15;
  6.         windowRect = new Rect(50, _amnt / 2, Screen.width - 100, Screen.height - _amnt);
  7.         windowRect = GUILayout.Window(0, windowRect, MenuWindow, "");
  8.  
  9.             if (showPopUp) {
  10.             GUI.Window(0, new Rect((Screen.width / 2) - 200, (Screen.height / 2) - 150, 400, 300), popUp, "");
  11.         }
  12.     }
  13. }
  14.  
  15. void popUp(int windowID) {
  16.     GUILayout.Space(50);
  17.     GUILayout.Box("Please leave all analog inputs in their neutral positions.");
  18.     GUILayout.Space(30);
  19.  
  20.     if (GUILayout.Button("Click here when ready.", _menuButtonsString)) {
  21.         Calibrate();
  22.         showPopUp = false;
  23.     }
  24. }
  25.  
  26. void MenuWindow(int windowID) {
  27.     GUILayout.BeginHorizontal("box");
  28.     float _buttonWidth = (windowRect.width / 3) - 50;
  29.     GUILayout.Label("Action", _menuHeaderString, GUILayout.Width(_buttonWidth + 8));
  30.     GUILayout.Label("Primary", _menuHeaderString, GUILayout.Width(_buttonWidth + 8));
  31.     GUILayout.Label("Secondary", _menuHeaderString, GUILayout.Width(_buttonWidth + 8));
  32.     GUILayout.EndHorizontal();
  33.  
  34.     _scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
  35.     GUILayout.BeginHorizontal();
  36.  
  37.     GUILayout.BeginVertical();
  38.  
  39.     for (int n = 0; n < cInput.length; n++) {
  40.         GUILayout.BeginHorizontal();
  41.         GUILayout.Label(cInput.GetText(n, 0), _menuActionsString, GUILayout.Width(_buttonWidth));
  42.  
  43.         if (GUILayout.Button(cInput.GetText(n, 1), _menuInputsString, GUILayout.Width(_buttonWidth)) && Input.GetMouseButtonUp(0)) {
  44.             if (Time.realtimeSinceStartup > mouseTimer) {
  45.                 cInput.ChangeKey(n, 1);
  46.             }
  47.         }
  48.  
  49.         if (GUILayout.Button(cInput.GetText(n, 2), _menuInputsString, GUILayout.Width(_buttonWidth)) && Input.GetMouseButtonUp(0)) {
  50.             if (Time.realtimeSinceStartup > mouseTimer) {
  51.                 cInput.ChangeKey(n, 2);
  52.             }
  53.         }
  54.         GUILayout.EndHorizontal();
  55.     }
  56.     GUILayout.EndVertical();
  57.  
  58.     GUILayout.EndHorizontal();
  59.     GUILayout.EndScrollView();
  60.  
  61.     GUILayout.Space(20);
  62.     GUILayout.BeginHorizontal("textfield");
  63.  
  64.     if (GUILayout.Button("Reset to defaults", _menuButtonsString, GUILayout.Width(_buttonWidth + 10)) && Input.GetMouseButtonUp(0)) {
  65.         cInput.ResetInputs();
  66.     }
  67.  
  68.     if (GUILayout.Button("Calibrate joysticks", _menuButtonsString, GUILayout.Width(_buttonWidth + 10)) && Input.GetMouseButtonUp(0)) {
  69.         showPopUp = true;
  70.     }
  71.  
  72.     if (GUILayout.Button("Close", _menuButtonsString, GUILayout.Width(_buttonWidth + 10)) && Input.GetMouseButtonUp(0)) {
  73.         _showMenu = false;
  74.     }
  75.  
  76.     GUILayout.EndHorizontal();
  77. }
  78.  
  79. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement