HollettGaming.Com
Fun, Free Online Games
Open/Close MenuMENU
 
 

Unity Tips - Adding headings and tooltips

Unity Tips - Adding headings and tooltips

I thought I would give something back to the Unity community as everyone has been so helpful to me in the past.

 

This article will show you how to add headings, spacing and tool tips to your unity scripts so that they are spaced out and more organised in the 'inspector' view.


I found this extreemly helpful in viewing my variables and objects in a more organised manner than one big long list.


As soon as I found out about this, I added it to every script!

What's more, this is actually extreemly easy to do.

 

These are just extra lines you add to the script, below are examples in C Sharp, I'm sure these will work equally well on other languages.
 

 

1) Headings
These are the most handy one, they add a nice bold heading above your variables in the inspector.
Simply add this where you want the heading to show:
[Header("My Heading:")]

 

 

Simple!

 

2) Spacing
A nice one to separate things out a bit, you can decide how much of a gap to add with the value in brackets.
Simply add this line where you want a gap to appear:
[Space(10)]

 

 

Easy!

 

3) Tooltips
More helpful to remind you want this parameter is for, without the need to open your script and read any comments you made.
This one needs to go ABOVE the line you want to add a tool tip for, eg:

[Tooltip("My Strings Tool Tip")]
public string MyString = "Some string value";

 


And here is how your code might look once you add all these:

 

 

We hope you found this useful.
Happy coding!

Written by Ford Hollett

Comments:

  • Submit A Comment/Review:
  • Name:
  • Email: (Required but won't be shown.)
  • Comment:
Back to News
 
 
back to topTop