Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class CharBuffer : MonoBehaviour
- {
- public string buffer;
- private const int size = 32;
- void Update()
- {
- for (KeyCode keyCode = KeyCode.A; keyCode <= KeyCode.Z; keyCode++)
- {
- if (Input.GetKeyDown(keyCode))
- {
- if (buffer.Length >= size)
- buffer = buffer.Substring(1, buffer.Length-1);
- buffer += ((char)(((int)keyCode - (int)KeyCode.A) + (int)('A')));
- }
- }
- for (KeyCode keyCode = KeyCode.Alpha0; keyCode <= KeyCode.Alpha9; keyCode++)
- {
- if (Input.GetKeyDown(keyCode))
- {
- if (buffer.Length >= size)
- buffer = buffer.Substring(1, buffer.Length - 1);
- buffer += "" + ((int)keyCode - (int)KeyCode.Alpha0);
- }
- }
- }
- public bool Contains(string match)
- {
- if (buffer.Contains(match.ToUpper()))
- {
- buffer = "";
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement