【问题标题】:Using decimals in GUI.Box in Unity C#在 Unity C# 的 GUI.Box 中使用小数点
【发布时间】:2012-08-23 04:27:40
【问题描述】:

我有一个关于统一 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 采用浮点值?为什么我不能使用十进制数。

提前致谢, 西班牙文

【问题讨论】:

  • 仅供参考 400.5 是文字浮动。不是文字小数,即 400.5M
  • @Surfbutler 实际上 400.5 是一个文字 double,而不是浮点数。
  • 是的,你是对的(但绝对不是小数)。

标签: c# user-interface decimal unity3d


【解决方案1】:

它可能不知道 400.5 是什么。

试试:

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

【讨论】:

    猜你喜欢
    • 2016-10-23
    • 1970-01-01
    • 2014-02-23
    • 2014-08-07
    • 1970-01-01
    • 2012-08-21
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    相关资源
    最近更新 更多