Hello everyone…Here I have a code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class RandomNumbers : MonoBehaviour {
public Transform mCanvas;
public GameObject answerPanel;
public InputField answer;
public Text[] numbers;
bool activate = true;
public int suma;
int idx = 0;
void Start()
{
Shuffle(numbers);
StartCoroutine("CreateNum");
}
IEnumerator CreateNum()
{
yield return new WaitForSeconds(3f);
while (idx < numbers.Length)
{
if (activate)
{
Text g = Instantiate(numbers[idx], new Vector3(Random.Range(-450, 450), Random.Range(-450, 450), 0), Quaternion.identity);
g.transform.SetParent(mCanvas, false);
}
yield return new WaitForSeconds(2f);
++idx;
if(idx >= 6)
{
activate = false;
answerPanel.SetActive(true);
}
}
}
public void Shuffle<T>(IList<T> list)
{
int n = list.Count;
while (n > 1)
{
n--;
int k = Random.Range(0, n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
// Update is called once per frame
void Update() {
}
}
This code displays 6 random numbers on the screen. How is it possible to make these numbers multiply?And their value can be saved somewhere, for example, in a text.?