If you need a public variable in your script (so the other scripts can use this variable), but you don't want it exposed to inspector. See below example, the public
hidenProperty it not visible in the inspector.
Add a comment in the inspector for the variables used in the script. This is especially useful when you have tons of variables. See below example: two attributes,
myBag have their comments above in the inspector:
On the opposite of the
[SerializeField] makes a private variable of a script visible in the inspector.
Make a space in the inspector, to organize the attributes and variables in the inspector:
Every time when we create
float varibles, it would be better to put a range on it. As in some scenarios, it is not just us put the value here, there are might be some other people, such as testers (testers are friends 😎) want to play with different value and we don't want them to put some crazy value. i.e speed, weight, attack and etc. See following example of variable Speed: