I'm making a calculator game for my final project in a beginning scripting class. The premise of it is that randomly generated numbers are falling from the top of the scene, and when they hit a collider at the bottom, it plays a game over screen. You can only use a button once, and then you cannot click it again. If you use the calculator to come up with an equation that solves one of the falling numbers (for example, a 7 is falling. You use the calculator to type in 5+2 and the 7 will be solved), the number, which is a text UI, will be destroyed.
I have all this done, except for the part where the numbers are destroyed upon solving them. I've tried a simple if statement, where if the result.text (a variable that shows the product of the calculator input) equals the random.text, then the randomly generated number should be destroyed.
Below is my code, if needed to help:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class CalcScript : MonoBehaviour {
public InputField input1;
public InputField input2;
public Text result;
int number;
float quotient;
bool useInput2 = false;
int random;
public Text random1;
public int[] values;
void Start () {
random = Random.Range(1,10);
random1.text = random.ToString();
print(random);
}
public void Addition () {
gameObject.GetComponent
↧