Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Create a list with multiple input fields

Discussion in 'Scripting' started by TomSa99, Sep 25, 2023.

  1. TomSa99

    TomSa99

    Joined:
    Mar 21, 2023
    Posts:
    5
    Hello there! I have two different input fields, that create two different variables, Reaction and Expression Rate, i also have a button that clones those two input fields so that the user can add more reactions and its expression rate. I want to be able to create two different lists, a list with all the reactions and another list with all the respective expression rates.
    Right now i still can't access the values for the added input fields, because all that the button does is duplicate the GameObject with the input fields and the script i have it's only attached to the original input fields.

    Thank you for your assistance, I apologize if it is very poorly explained and if further clarification is needed, please let me know!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    See attached for my example of dynamically created UI and how to hook it up so you can access individual parts inside of it.
     

    Attached Files:

    TomSa99 likes this.
  3. TomSa99

    TomSa99

    Joined:
    Mar 21, 2023
    Posts:
    5
    Hey thanks for the help i really appreciate it, this is great!
    What i have is a little script in a button that basically clones a GameObject, in this case an input field, and that as a script to store the input, the clone also gets the script, but if i write something in the clone it just basically stores on top of the previously written, and i would like to store the new input into a list, so that i can use all those inputs from the different input fields, in another script.
    I will try to make it work with what you gave me.
    Thanks again, you have been more helpful than my dissertation advisors.
     
  4. TomSa99

    TomSa99

    Joined:
    Mar 21, 2023
    Posts:
    5
    I just came back here to say that i was able to solve my problem, i was complicating things when it was just something really simple, and i came to the solution when replying to you and putting to words the problem.
    Thank you one more time, what you sent me will definitely help in the future because i ended up finding new things that i didn't knew! :)
     
    Kurt-Dekker likes this.