- Home /
Pull a random input field from one scene into another
I have a scene that has up to 6 user input fields. I want the next scene to be able to access these fields and randomly pick and display one. From the research I have gathered, it seems to me like I need a script that uses Don'tDestroyonLoad. After that, I'm totally lost. Any help would be much appreciated.
Answer by KuR5 · Jun 16, 2016 at 06:30 AM
Hi @Gaege,
After that you can store the value of each input fields in the array of string. Then use Random.Range(0,array.length) to get the random index and use that index to get the element from the array.
ex.
Let's take an array of string named inputValues
Fill inputValues array with the value of each input fields
Then get the random index value by using Random.Range() and use it as below.
inputValues[Random.Range(0,inputValues.Length)] gives you a random value.
Thank you for your response. This got me on the right track, my only question now is how would I direct the input fields to fill the input values array?