简体   繁体   中英

Using decimals in GUI.Box in Unity C#

I have a question about C# in unity:

How come this code works:

GUI.Box(new Rect((Screen.width/2)-200,0,400,30) , "King of the hill");

While this one don't

GUI.Box(new Rect((Screen.width/2)-200,0,400.5,30) , "King of the hill");

The error I get is this:

The best overloaded method match for `UnityEngine.Rect.Rect(float, float, float, float)'   
has some invalid arguments

Doesn't this error imply that the GUI.Box takes float values? Why can't I use a decimal number.

Thanks in advance, Spagnum

It's possible that it doesn't know what 400.5 is.

try :

GUI.Box(new Rect((Screen.width/2)-200,0,400.5f,30) , "King of the hill");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM