Question by
rol040pangan · Jan 04, 2019 at 04:03 PM ·
validation
Matchmaking Words using Buttons as Custom Keyboard
Hi everyone I am new in game development, in my first development I am trying to validate if the the words if they are match with the input, unfortunately the only word it finds correct is the last value in the array I created and the other words are incorrect. Here are the sample codes and screenshots.
C# code here:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class MatchLetters : MonoBehaviour {
public string word = null;
public int wordIndex = 0;
public string alpha;
public Text WordMatch;
public Text Question;
public string name;
public string[] quest;
int num;
public List<string> Words;
// Use this for initialization
void Start () {
TextAsset wordText = Resources.Load<TextAsset> ("Words");
quest = wordText.text.Split ("\n" [0]);
}
// Update is called once per frame
void Update () {
// Question.text = quest[Random.Range(0, quest.Length)];
}
public void AlphabeticFunction(string alphabet){
wordIndex++;
word = word + alphabet;
WordMatch.text = word;
}
public void WordsGenerate (){
name = Question.text = quest[Random.Range(0, quest.Length)];
}
public void ValidateAnswer (){
if (name == WordMatch.text) {
Question.color = Color.green;
Debug.Log ("Correct");
} else {
Question.color = Color.red;
Debug.Log ("Incorrect");
}
}
public void ResetAnswer(){
wordIndex = 0;
word = "";
WordMatch.text = word;
}
}
screenshot-82.png
(124.4 kB)
screenshot-83.png
(124.2 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612185059im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
public members not assigned OnValidate 0 Answers
Is there no way to inherit children's components for validation/checking purposes? 1 Answer
OnValidate For Other Components? 0 Answers
How to Test Unity Analytics? 0 Answers
How do you add to an array with "...[]" & reset a selector to avoid duplication 0 Answers