I want my game to pop up an input field when the user presses space on an object, which in this case is a skeleton. I want it so the user can see a simple math question, and answer the question using the input field, but I have no idea where to start. I have the code that displays a dialog box when space is pressed but I don’t have the input field popping up. Thank you in advance. ![alt text][1]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SkeletonMath : MonoBehaviour {
public GameObject dialogBox;
public Text dialogText;
public string dialog;
public bool playerInRange;
public GameObject guess;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.Space) && playerInRange)
{
if(dialogBox.activeInHierarchy)
{
Time.timeScale = 1f;
dialogBox.SetActive(false);
}else{
Time.timeScale = 0f;
dialogBox.SetActive(true);
dialogBox.text = dialog;
guess.SetActive(true);
}
}
}
private void OnTriggerEnter2D(Collider2D other)
{
if(other.CompareTag("Player"))
{
//playerInRange = true;
}
}
private void OnTriggerExit2D(Collider2D other)
{
if(other.CompareTag("Player"))
{
playerInRange = false;
dialogBox.SetActive(false);
}
}
}