Sign in to follow this  

What is the Unity equivalent of console.Readline?

Recommended Posts

Thus far I've trained only in C# using VS. I'm brand new to the Unity interface and working through some Udemy courses.

What is Monodevelop line for storing user input into a string or int? Example, having the game ask what the users name is, or what the users age is?

Share this post


Link to post
Share on other sites

There isn't one. The concept of 'standard input' doesn't exist in Unity applications.

To read text input from the player in Unity usually involves creating a UI Canvas, adding a Text control, adding an Input Field to that... it's not trivial. This is probably something you will want to postpone until you have worked through a UI tutorial.

Share this post


Link to post
Share on other sites

I recommend learning the UI system.  It becomes trivial once you run through a few tutorials.

If you don't want a UI, you can use Input.inputString to get the string of characters that have been pressed since the last frame, and append those to a StringBuilder until the enter key is pressed.  I've used this for developer cheat codes (think of cheat codes from pre-Quake days) in a game I worked on.

Edited by Nypyren

Share this post


Link to post
Share on other sites
On 9/19/2017 at 10:17 AM, Kylotan said:

This is probably something you will want to postpone until you have worked through a UI tutorial.

Ah! Thanks for the strait answer. I'm going through the Udemy stuff now. The Ben Tristam course starts you out writing command lines to the Unity Console....I was like "hey, this is familiar", but quickly found out it's not lol.

21 hours ago, Nypyren said:

you can use Input.inputString to get the string of characters that have been pressed since the last frame,

Thanks! I'll keep an eye out for that line in the tutorials :D Much appreciated.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this