官术网_书友最值得收藏!

The Range attribute

Another thing that we can use to protect our code is the Range attribute. This will allow us to specify a minimum and maximum value for a variable. Since we want the player to always be moving forward, we may want to restrict the player from moving backward. To do that, we can add the following highlighted line of code:

    [Tooltip("How fast the ball moves forwards automatically")] 
[Range(0, 10)]
public float rollSpeed = 5;

Save your script, and return to the editor:

We have now added a slider beside our value, and we can drag it to adjust between our minimum and maximum values. Not only does this protect our variable, it also makes it so our designers can tweak things easily by just dragging them around.

主站蜘蛛池模板: 陇南市| 东阿县| 百色市| 格尔木市| 方山县| 神池县| 壤塘县| 怀宁县| 宜兰市| 双桥区| 鹿邑县| 普兰店市| 江孜县| 徐州市| 合江县| 句容市| 筠连县| 油尖旺区| 新田县| 墨玉县| 阿拉善左旗| 乐亭县| 久治县| 运城市| 中山市| 辛集市| 抚松县| 兴安县| 怀化市| 桂东县| 南康市| 沾化县| 藁城市| 东兰县| 莱芜市| 抚宁县| 西峡县| 盱眙县| 林芝县| 龙海市| 苏尼特左旗|