- Home /
 
To see chosen random text UI Unity,To Access UI text
I can see it on game which number is chosen but i can't access it. Only i can see all random numbers while game run. I wanna access the Text ui after random function stop and decide which number it is. Also I did same thing 3 times. I mean like a casino slots. I have 3 slots each slots stop to roll after 1 sec. So all numbers will stop after 3 seconds. When i print it i see all numbers chosen and not chosen. i wanna see only 3.
using UnityEngine; using UnityEngine.UI;
public class DiceRoller : MonoBehaviour { readonly char[] _numbersRandom = { '1', '2', '3', '4', '5' }; public Text SlotNumber; private Text _chosenAttackDamage; public float Time;
 void Update()
 {
     SlotNumber.text = _numbersRandom[Random.Range(0, _numbersRandom.Length)].ToString();
     OffEnable();
     //_chosenAttackDamage = SlotNumber;
     //print(_chosenAttackDamage.text);
 }
 public void OffEnable()
 {
     Invoke("DelayNum", Time);
     
 }
 public void OnEnable()
 {
     enabled = true;
 }
 void DelayNum()
 {
     enabled = false;
 }
 
               },I have 3 slots and in each slots appear 1 random number between 1 to 5: Problem is: when i wanna to access what is chosen number i can't do this. I can see all numbers while looping until it stops. Anybody could help me? I want to access which number it is cuz I will create decision if 3 do that if 4 to this
using UnityEngine; using UnityEngine.UI;
public class DiceRoller : MonoBehaviour { readonly char[] _numbersRandom = { '1', '2', '3', '4', '5' }; public Text SlotNumber; private Text _chosenAttackDamage; public float Time;
void Update(){SlotNumber.text = _numbersRandom[Random.Range(0, _numbersRandom.Length)].ToString();OffEnable();//_chosenAttackDamage = SlotNumber;//print(_chosenAttackDamage.text);}public void OffEnable(){Invoke("DelayNum", Time);}
Your answer
 
             Follow this Question
Related Questions
How to change UI button of a particular gameobject to another UI button 1 Answer
How to change UI button of a particular gameobject to another UI button 0 Answers
if statement not working for user input 0 Answers
How do I call an DontDestroyOnLoad function on UI text 2 Answers
Changing the UI text value from server to Client side 0 Answers