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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

use InputField value in script

Discussion in 'Scripting' started by Bennytha, May 1, 2017.

  1. Bennytha

    Bennytha

    Joined:
    Dec 15, 2016
    Posts:
    3
    I would like to take in value for the editor, I have created a InputField which takes in only number.
    now i want to bring the values in to script as integer and manipulate it.
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Is this an editor script or an inputfield from a scene/game?

    What does your script look like so far?
     
  3. Bennytha

    Bennytha

    Joined:
    Dec 15, 2016
    Posts:
    3
    im working with c#, how do I assign the value from the inputfield to an int variable in c#?

    My script looks bad!:D
     
  4. x3r

    x3r

    Joined:
    May 25, 2016
    Posts:
    46
    Use UnityEngine.UI

    Create field "public InputField someText" before public void Start() and drag your InputField there(in the inspector).Now you can access that control in your script.
     
    TaleOf4Gamers likes this.
  5. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    if you use the previous poster's example, you can get the input from "someText.text" :)
     
  6. rtanwar616

    rtanwar616

    Joined:
    Feb 5, 2018
    Posts:
    3
    can we assign inputfield data to a string variable ?
     
  7. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
  8. luzespanhol1

    luzespanhol1

    Joined:
    Jun 26, 2022
    Posts:
    2
  9. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,954
    Rather than necro-posting to five-year-old threads, start your own post... it's FREE!

    Remember that NOBODY can read your mind. YOU need to communicate clearly.

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    This is the bare minimum of information to report:

    - what you want
    - what you tried
    - what you expected to happen
    - links to documentation you used to cross-check your work (CRITICAL!!!)
    - what actually happened, especially any errors you see

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/