So, I have been working at this for over a week now, and I can’t get, for example, userInput to show up in the component drop down for a script on an empty game object. Or how you’re supposed to be able to drag userInput from the Hierarchy, and drop it into the property slot. I feel like this is really simple, and it’s something I’m completely missing,
using UnityEngine;
using UnityEngine.UI;
public class GameLogic : MonoBehaviour
{
public InputField userInput;
public Text gameLabel;
private int randomNum;
// Start is called before the first frame update
void Start()
{
randomNum = 10;
}
// Update is called once per frame
void Update()
{
}
public void OnButtonClick()
{
string userInputValue = userInput.text;
if (userInputValue != "")
{
int answer = int.Parse(userInputValue);
if (answer == randomNum)
{
gameLabel.text = "Correct!";
}
else if (answer > randomNum)
{
gameLabel.text = "Try Lower!";
}
else
{
gameLabel.text = "Try Higher!";
}
}
else
{
gameLabel.text = "Enter a number!";
}
}
}