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

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.

主站蜘蛛池模板: 平舆县| 丰县| 囊谦县| 驻马店市| 永吉县| 拜城县| 通城县| 南开区| 碌曲县| 余庆县| 兴化市| 济源市| 镇平县| 德保县| 东丽区| 津南区| 苏尼特右旗| 青田县| 呈贡县| 云霄县| 玉溪市| 城固县| 大渡口区| 万年县| 扎兰屯市| 义乌市| 广昌县| 闽侯县| 荔浦县| 抚松县| 泸水县| 喀什市| 博爱县| 新余市| 余庆县| 莱芜市| 家居| 和顺县| 延安市| 开原市| 桂东县|