- Home /
showing variables
how can i show variables on screen.. example is you declare a var = 10; then it is printed on the screen..
'cause the error says "no appropriate version" , "convert string to float" (i've tried var : float = 10;) , i also try GUIelement but it doesn't work. a little help please :) i cant find it in the references even in the scripting references
Answer by AlucardJay · Mar 08, 2013 at 05:33 PM
Ok, so I'm guessing the problem is you are trying to show a value in the GUI, and that value is not a string?
// static function Label (position : Rect, text : String) : void
GUI.Label (Rect (10, 10, 100, 20), "Hello World!");
So GUI needs a string. How to convert an integer or a float to a string? Append ToString() after your variable :
GUI.Label( Rect( 10, 10, 100, 20 ), "" + myFloat.ToString() );
Your answer
![](https://koobas.hobune.stream/wayback/20220613094046im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Make GUI elements disappear 3 Answers
NOT auto resizing GUI, keeping GUI always the same aspect ratio 0 Answers
GUI - Scale GUIs According to Resolution 6 Answers
Render Sprite on Screen at 3d game 0 Answers