UNITY3D:是否有一种简单的方法可以使检查员中的值分钟/最大值



我试图弄清楚如何在检查员中给出最小值和最大值。

例如:

public float testValue;

我知道我可以使用/else语句设置代码中的最小值和最大值,但这将与很多变量混乱。该测试值将在Unity Inspector中为Visibile。

我想让这个值的最大值为100,最小值是0。是否有一种奇特的方法来执行此操作,而不是很多语句?

谢谢:(

检查范围属性:

这样使用:

[Range(0, 100)]
public float testValue;

尝试以下:

[Range (0f,100f)] public float testValue;

可能这个

[Range(0.0f, 10.0f)]
public float mySliderFloat;

确实有一种奇特的方法可以做到这一点。随着范围声明:[Range(min, max)]

https://unity3d.com/learn/tutorials/topics/tips/show-public-variables-sliders-sliders-rangemin-max

相关内容

最新更新