Attributes in Unity 2020


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.

HideInInspector in Unity


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, speed and myBag have their comments above in the inspector:

[Header] in Unity


On the opposite of the [HideInInspector], [SerializeField] makes a private variable of a script visible in the inspector.

SerializeField in Unity


Make a space in the inspector, to organize the attributes and variables in the inspector:

Space in Unity


Every time when we create int, 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:

Range in Unity


Originally published at on June 25, 2020.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Toymail Redesign — Case Study

Buying vs Building a Learning Management System

G2 Grid® for Learning Management System (LMS)

How to pass the challenge for Cosmos Gaming Hub

How to Have a Better Stack Overflow Experience

Week 5: Optimizations with just the compiler!

The best folder structure for your project!

Day 27/100daysofK8s


Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Needone App

Needone App

More from Medium

JEFF Introduction: Solutions(2)

Breast Cancer Detection

The Pomodoro Technique: Eat that Frog

Outlier detection using IQR