Unity Tips Collection

By 09/11/2018 March 20th, 2019 General

Each Tuesday users post their tips about Unity to share shortcuts to all devs, improve the workflow and make things easier for everyone.
Here’s my Unity Tips collection; I post one tip on Twitter each week and I add it here.
You can follow me on twitter to stay updated about all my posts and never miss anything.


Support me

If you like my content and would like to support me, please consider sharing my website and/or supporting me on Patreon, so I can keep producing free quality content for everyone.


Here’s a quick map of this post:


Show the content of multiple folders

You can see the content of multiple folders by selecting them in the Project Window.

unity febucci tips unitytips show content inside multiple folders project window


Customize Unity’s C# template 

You can customize Unity’s C# template by changing the “81-C#” file found in the path: “%EDITOR_PATH%\Data\Resources\ScriptTemplates”.
Remember to store a copy before modifying it!

You can find more info here.
P.S. when saving a copy of the original file, I recommend moving it into another folder or not naming it starting with “81-C#”.

change csharp c# template default unitytips febucci tutorial unity tips


Console Window Log Entries

You can adjust the number of lines shown for each Log in the Console Window, to read more (or less) text per entry.

febucci console window log entries unitytips post #unitytips unity tips


OnValidate

You can make sure you entered the right value in the Inspector by helping you with the OnValidate function.
Read more here.

unitytips post


Set Editor Presets as Default

You can set Editor Presets as default and then apply them by pressing “Reset”

unity presets default #unitytips reset


Editor color in Play Mode

You can remind yourself that the Editor is in Play Mode by changing its “Playmode tint”.


Drag/select scenes in the build settings

You can drag multiple scenes in the build settings and enable/disable them at the same time (instead of one by one).


Fold the entire Hierarchy

You can fold the entire Hierarchy using the following code.
This way you’ll collapse all the GameObjects in the window with a simple click (mostly useful if you also add a keyboard shortcut).

Read more about the Hierarchy window and Unity Hotkeys.
Sources: Unity forum, Unity answers.

febucci unitytips unity fold entire hierarchy gameobjects


Rich text in the console

You can use rich text in Unity’s console.
Read more about Rich Text.


Asset store search in project window

You can search through the Asset Store directly from your project window.


DisallowMultipleComponent & RequireComponent

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

Read more about DisallowMultipleComponent and RequireComponent


Graphy

You can monitor the performance of your games directly from your builds using this great tool made by @tayx94.

GitHub repository here.


Drag multiple items in the inspector

You can drag multiple items in an array by locking the Inspector.


Unity Visual Search

You can easily find 3D models for your game using Unity Visual Search and preview them in the Editor.
For example, it comes super handy if you’re building a prototype.

Asset Store page (it’s free).


NaughtyAttributes

You can use 20+ handy attributes made by dbrizov on GitHub, like a ReorderableList, a Slider or a ResizableTextArea.

GitHub repository here.


Foldout

You can group variables in the Inspector using the Foldout attribute, made by dimmpixeye on GitHub.
GitHub repository here.


Scene Icons

You can assign icons for GameObjects and Scripts.
Read more here.


ContextMenu

Call methods from the Inspector by using the ContextMenu attribute.
Read more here.


Inspector Math Expressions

You can enter math expressions in the Inspector.


SerializeField & HideInInspector

Choose which variable to show and serialize by using the attributes SerializeField and HideInInspector.
Read more here: SerializeField and HideInInspector.


FormerlySerializedAs

Useful if you need to rename a variable without losing its serialized value.
Read more here.


AddComponentMenu

Organize your scripts in the “AddComponent” Menu in the Inspector by using the AddComponentMenu attribute.
Read more here.


MenuItem

Call methods from the Main Menu and Inspector Context Menus. Be aware that it only works in the Editor, so you need to cut it if you want to release that code. (Add #if UNITY_EDITOR and you’re good to go).
Read more here.


That’s it for now, remember that I update this post each week, so stay tuned!

Follow me on twitter to never miss my posts, see you next time and have a nice day!