Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class keysGUI : MonoBehaviour {
- public char[] rightHandKeys = { 'y', 'u', 'i', 'o', 'p',
- 'h', 'j', 'k', 'l',
- 'n', 'm' };
- public char[] leftHandKeys = { 'q', 'w', 'e', 'r', 't',
- 'a', 's', 'd', 'f', 'g',
- 'z', 'x', 'c', 'v', 'b' };
- public Font keyFont;
- public char currentKeyRight;
- public char currentKeyLeft;
- public char tempRight;
- public char tempLeft;
- void Start()
- {
- currentKeyRight = rightHandKeys[Random.Range(0, rightHandKeys.Length)];
- currentKeyLeft = leftHandKeys[Random.Range(0, leftHandKeys.Length)];
- tempRight = currentKeyRight;
- tempLeft = currentKeyLeft;
- }
- void OnGUI()
- {
- GUIStyle keys = new GUIStyle();
- keys.alignment = TextAnchor.MiddleCenter;
- keys.font = keyFont;
- keys.normal.textColor = new Color(255, 255, 255);
- keys.fontSize = 50;
- if (Time.time < 3.0F)
- {
- GUI.TextField(new Rect(0, 0, Screen.width, Screen.height*0.5F), "PLEASE PLACE YOUR HANDS ON THE KEYBOARD", keys);
- }
- else
- {
- //right hand
- GUI.TextField(new Rect(Screen.width * 0.5F, Screen.height * 0.8F, Screen.width * 0.5F, 40), currentKeyRight.ToString(), keys);
- if (Input.GetKey(currentKeyRight.ToString()))
- {
- tempRight = currentKeyRight;
- currentKeyRight = rightHandKeys[Random.Range(0, rightHandKeys.Length)];
- }
- //leftt hand
- GUI.TextField(new Rect(0, Screen.height * 0.8F, Screen.width * 0.5F, 40), currentKeyLeft.ToString(), keys);
- if (Input.GetKey(currentKeyLeft.ToString()))
- {
- tempLeft = currentKeyLeft;
- currentKeyLeft = leftHandKeys[Random.Range(0, leftHandKeys.Length)];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement