Create virtual keyboard on screen
Hi, I was wondering how to create a virtual keyboard manually, using buttons. when click to the buttons, text appear on screen. I created a code, but it only appear one letter only. How I could appear the text according to button click?
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class textAnswer : MonoBehaviour {
public Text Alphabet;
public void firstgame (string alphabet) {
Alphabet.text = alphabet;
string firstGameResult = alphabet;
if (firstGameResult == "e") {
Debug.Log ("correct");
}
keyboard.png
(82.4 kB)
Comment
Best Answer
Answer by See_Sharp · Apr 12, 2016 at 08:19 AM
You're always overwriting the text value of Alphabet. You could try something like:
Alphabet.text += alphabet;
This will append the text.
Yes! Thank you. This works. But another question. I want it to detect "me" if (firstGameResult == "me") when i debug the alphabet, it is not in one line.
me.png
(7.0 kB)
if(firstGameResult.Contains("me") ... ? This will return true if the string contains the string "me"