Advertisement

What is the Unity equivalent of console.Readline?

Started by September 19, 2017 02:13 PM
3 comments, last by jkuehlin 7 years, 5 months ago

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?

This is my placeholder signature

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.

Advertisement

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.

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.

This is my placeholder signature

This topic is closed to new replies.

Advertisement