2012-08-28 23 views
0

我有團結關於C#的一個問題:在GUI.Box使用小數在Unity C#

爲什麼此代碼的工作:

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

雖然這一個不

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

我得到的錯誤是這樣的:

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

不這個錯誤意味着GUI.Box採用浮點值?爲什麼我不能使用十進制數字。

由於提前, Spagnum

+0

FYI 400.5是文字浮動。不是一個字面十進制,這將是400.5M – Surfbutler

+0

@Surfbutler其實400.5是一個文字**雙**,而不是浮動。 – Tergiver

+0

是的,你是對的(但絕對不是小數)。 – Surfbutler

回答

1

這有可能是它不知道什麼是400.5。

嘗試:

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