Advertisement
Guest User

10finger_GUI

a guest
Nov 21st, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.03 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class keysGUI : MonoBehaviour {
  5.     public char[] rightHandKeys = { 'y', 'u', 'i', 'o', 'p',
  6.                                     'h', 'j', 'k', 'l',
  7.                                     'n', 'm' };
  8.     public char[] leftHandKeys = { 'q', 'w', 'e', 'r', 't',
  9.                                    'a', 's', 'd', 'f', 'g',
  10.                                    'z', 'x', 'c', 'v', 'b' };
  11.  
  12.     public Font keyFont;
  13.     public char currentKeyRight;
  14.     public char currentKeyLeft;
  15.  
  16.     public char tempRight;
  17.     public char tempLeft;
  18.  
  19.     void Start()
  20.     {
  21.        currentKeyRight = rightHandKeys[Random.Range(0, rightHandKeys.Length)];
  22.        currentKeyLeft = leftHandKeys[Random.Range(0, leftHandKeys.Length)];
  23.  
  24.        tempRight = currentKeyRight;
  25.        tempLeft = currentKeyLeft;
  26.     }
  27.     void OnGUI()
  28.     {
  29.         GUIStyle keys = new GUIStyle();
  30.         keys.alignment = TextAnchor.MiddleCenter;
  31.         keys.font = keyFont;
  32.         keys.normal.textColor = new Color(255, 255, 255);
  33.         keys.fontSize = 50;
  34.  
  35.         if (Time.time < 3.0F)
  36.         {
  37.             GUI.TextField(new Rect(0, 0, Screen.width, Screen.height*0.5F), "PLEASE PLACE YOUR HANDS ON THE KEYBOARD", keys);
  38.         }
  39.         else
  40.         {
  41.             //right hand
  42.             GUI.TextField(new Rect(Screen.width * 0.5F, Screen.height * 0.8F, Screen.width * 0.5F, 40), currentKeyRight.ToString(), keys);
  43.             if (Input.GetKey(currentKeyRight.ToString()))
  44.             {
  45.                 tempRight = currentKeyRight;
  46.                 currentKeyRight = rightHandKeys[Random.Range(0, rightHandKeys.Length)];
  47.             }
  48.  
  49.             //leftt hand
  50.             GUI.TextField(new Rect(0, Screen.height * 0.8F, Screen.width * 0.5F, 40), currentKeyLeft.ToString(), keys);
  51.             if (Input.GetKey(currentKeyLeft.ToString()))
  52.             {
  53.                 tempLeft = currentKeyLeft;
  54.                 currentKeyLeft = leftHandKeys[Random.Range(0, leftHandKeys.Length)];
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement