I want to create a safety check in a game for children so only the parents can access a specific area. The script of checking the input is done and working. What I am trying to create is a feedback to see what number is already clicked. Parents must enter a certain sequence of numbers. For example they have to click "Five" and when they do I want to text to change to be italic.
If a wrong number is entered, you have to start the whole entry from the beginning (already scripted). That means if they click a wrong number the text have to go from italic to normal.
Here you can see the way it should look. I am using Text.MeshPro for the texts
It would be super awesome if someone could help me :)
I really have no idea what I am doing. For creating the general safety check, I used the following script:
using DefaultNamespace.Logging;
using DefaultNamespace.ParentSecurity;
using DefaultNamespace.SceneManager;
using UnityEngine;
public class ParentSecureController : MonoBehaviour
{
public SceneManager sceneManager;
public SceneNames targetSceneName;
private readonly int[] code = new int[5]
{
5, 3, 4, 1, 2
};
private int index;
private void Start()
{
foreach (var numberItem in GetComponentsInChildren<NumberItem>()) numberItem.SetParentSecureController(this);
}
// Update is called once per frame
public void CheckInput(int number)
{
CustomLogger.Log("In CheckInput, code:" + code);
CustomLogger.Log("In CheckInput, index:" + index);
CustomLogger.Log("In CheckInput, nbr:" + number);
if (number == 0) return;
if (index >= 4)
sceneManager.LoadScene(targetSceneName);
else if (number == code[index])
index++;
else
index = 0;
}
}
In general you can simply change that via
Then as said I would rather insert some randomness instead of a hard-coded code.
First of all I would have an
enumfor simply having names and values together:and then there are two different UI items
I would have
The component attached to the button prefab
and for the UI display text e.g.
and then finally as mentioned do some randomization of the numbers and do