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

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.

主站蜘蛛池模板: 南华县| 石屏县| 固始县| 房产| 班戈县| 大渡口区| 甘泉县| 沁水县| 沙田区| 麻阳| 台南县| 普兰店市| 新巴尔虎右旗| 宜春市| 桃江县| 汉中市| 天长市| 满洲里市| 巴彦县| 姚安县| 界首市| 唐山市| 内乡县| 大安市| 辛集市| 英德市| 高清| 楚雄市| 西青区| 三明市| 龙里县| 宝坻区| 卢龙县| 莱州市| 德江县| 景宁| 大洼县| 赤壁市| 石嘴山市| 阜康市| 吴忠市|