Compilation of useful tips for Unity gathered from around Twitter.
The list below features various tips and tricks for Unity for the different areas, ranging from UI, Editor workflow, all the way to programming and level design.
1. Scene view GUI button
Do you want to display GUI elements in the Scene View to make development steps faster and easier? Add a static method of your choice to the onSceneGUIDelegate and draw everything you want.
@rehawk
2. .NET 4.x null-conditional operators
Switching to .NET 4.x in the player settings of your Unity projects give you loads of neat C# 6 features! Here are my three favorites #unitytips
Null-conditional operators are great to avoid loads of extra code just to do sequential null checking
@FreyaHolmer
3. DisallowMultipleComponent and RequireComponent
You can use the attributes DisallowMultipleComponent and RequireComponent to avoid setup errors in your gameObjects.
@febucci
4. Menu item shortcuts
You can add keyboard shortcuts to your menu items in @unity3d.
Add % for Ctrl/Cmd, # for Shift, & for Alt before your hot key. If you don't want a combination, adding underscore _ before your key will do.
@sgt3v
5. Non-alloc collision contacts
WOAAAAAA!!! #Unity3d has no GC allocs for getting collision contacts anymore with a new GetContacts(contactsBuffer) method in 2018.3! Been waiting this for ages. This is like the only reason I need to expedite my move to 2018 now :)
@Nothke
6. SerializeField for editing private variables
Don't use the "public" access modifier just to edit a field from the Inspector. Use [SerializeField] attribute instead.
@tntcproject
7. Inspector lock
Did you know that you can drag multiple items in an array by locking the Inspector?
@febucci
8. Object mirroring
Hey Lvl Designers! Wanna have a mirror object like this statue... Just change the scale to -1
@MrTeels
9. Easy two-sided shader
Do you want two-sided materials but are too afraid to delve too deep into the dark art of shader coding? Just create a new standard surface shader and add the words "Cull off" after the "LOD" line. Works with unlit shaders too!
@HarryAlisavakis
10. Run static method before or after scene load
There is a way to execute code in your scripts without having to create an empty GameObject with a MonoBehaviour. The [RuntimeInitializeOnLoadMethod] command allows you to execute methods before and after the scene loads. Useful to do some initialization and cleanup.
@arturonereu