use InputField value in script

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.

Is this an editor script or an inputfield from a scene/game?

What does your script look like so far?

im working with c#, how do I assign the value from the inputfield to an int variable in c#?

My script looks bad!:smile:

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.

1 Like

if you use the previous poster’s example, you can get the input from “someText.text” :slight_smile:

can we assign inputfield data to a string variable ?

https://docs.unity3d.com/ScriptReference/UI.InputField-text.html

i cant assign the input in the variable

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://discussions.unity.com/t/481379