How I can make a screen like a text editor, but only to display what the user writes?
Like a box were the user types something
There is only one way that >I< (and emphasis on “I”) I know of is if / if else. I have done lots of searching on this topic, and, haven’t really found anything. I don’t mean to mislead you or anything, so, you might want to do some more searching and ask around. That, or hopefully someone else can post a better answer than this one .
function Update ( )
{
if ( Input.GetKey ( KeyCode.C ) ){
//Do GUI stuff
}
if ( Input.GetKey ( KeyCode.B ) ){
//Do GUI stuff
}
if ( Input.GetKey ( KeyCode.C ) ){
//Do GUI stuff
}
}
Alternatively, If you want to keep Update a little cleaner, just create another function to pre-store variables, or use Start …
var KeyArray = new Array ( ) ;
function Start ( )
{
KeyArray.Add( KeyCode.A ) ;
KeyArray.Add( KeyCode.B ) ;
KeyArray.Add( KeyCode.C ) ;
}
function CheckKeys ( )
{
for ( var _keys ; _keys in KeyArray; _keys ++ )
{
if ( Input.GetKey ( KeyArray [ _keys ] ) )
{
//GUI CODE
}
}
yield WaitForSeconds ( 0.1 ) ; // May cause key latency, but better performance. See if this causes an issue for you.
}
//Though I am not sure if the second method is memory efficient. You will have to test that out.
function Update ( )
{
CheckKeys ( ) ;
}