[Code] Unity3d Quick Tip: Better Organize Variables in Inspector

Have you ever had problems organizing your variables in the Unity’s Inspector? Too many of them? Here’s a quick fix that helps a lot when dealing with scripts with many public variables.


You can use in your scripts the HeaderAttribute (here’s the link to Unity’s documentation) before the group of variables. Here’s the code snipet (c# code):

public InputForCar swiper;

public float shieldDuration;
public float strifeDuration = 3;
public float speedUpDuration = 5;
public float strifeMultiplier = 1.5f;
public float speedUpMultipleier = 1.5f;
public float timeBeforeKickIn = 0.1f;

[Header("Strife detection")]
public float radiusForStrife;
public Vector2 boxInvulnerability;

Very easy way to keep track of the groups of variables. Adds a plus to productivity.

Leave a Reply

Your email address will not be published. Required fields are marked *