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

Understanding component properties in Unity's Inspector

GameObjects have some components that make them behave in a certain way. For instance, select Main Camera and look at the Inspector panel. One of the components is the camera. Without that component, it will cease being a camera. It would still be a GameObject in your scene, just no longer a functioning camera.

Variables become component properties

Any component of any GameObject is just a script that defines a class, whether you wrote the script or the Unity's programmer did. We just aren't supposed to edit the scripts that Unity has written. This means that all the properties that we see in Inspector are just variables of some type. They simply store data that will be used by some method.

Unity changes script and variable names slightly

When we add our script to a GameObject, the name of our script shows up in the Inspector panel as a Component. Unity makes a couple of small changes. You might have noticed that when we added LearningScript to Main Camera, Unity actually showed it in the Inspector panel as Learning Script. Unity added a space to separate the words of the name. Unity does this modification to variable names too. Notice that the number1 variable is shown as Number 1 and number2 as Number 2. Unity capitalizes the first letter as well. These changes improve readability in Inspector.

主站蜘蛛池模板: 康保县| 托克逊县| 沙坪坝区| 共和县| 西峡县| 普陀区| 原平市| 旺苍县| 山阴县| 隆回县| 湘潭市| 铁力市| 博罗县| 元阳县| 洛阳市| 延庆县| 深水埗区| 太仆寺旗| 崇义县| 广州市| 泸水县| 那曲县| 合阳县| 米泉市| 同心县| 华安县| 南乐县| 安泽县| 和顺县| 巩留县| 西昌市| 洪江市| 榆树市| 临猗县| 蒙山县| 湘乡市| 崇文区| 察哈| 泌阳县| 沂南县| 宁明县|