Sharp Coder is reader-supported, meaning when you buy through links on our site, we may earn an affiliate commission.
HomeBlogUnityWorkflow

Unity Twitter Tips

0 Comments - Jan 11, 2019
595

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

onSceneGUIDelegate

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

C# 6 features

3. DisallowMultipleComponent and RequireComponent

You can use the attributes DisallowMultipleComponent and RequireComponent to avoid setup errors in your gameObjects.
@febucci

Sharp Coder Video Player

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

Sharp Coder Video Player

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

SerializeField

7. Inspector lock

Did you know that you can drag multiple items in an array by locking the Inspector?
@febucci

Sharp Coder Video Player

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

Sharp Coder Video Player

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

You Do Not Have To Do Everything Yourself
Search from thousands of ready-to-use Unity assets.
Visit Asset Store