Unity Tipps & Tricks

in #gamedev7 years ago (edited)

Header

UNITY3D: Tipps & Tricks

Hey, Steemians
Ive been working with the Unity engine for some years now.
As I have seen there are quite some game developers using Unity here on Steemit
and i just wanted to share some tipps and tricks with you, which can be helpful for beginners
but ive also tried to include some tipps that even more experienced users might not have known.

So lets get Started:

Header in Inspector:

You can add headers to your variables in the Inspector using [Header("Header goes here")]
Example:
Example

Spacing in Inspector:

You can add spacing above your variables in the Inspector.
For example uning [Space(10)] adds a spacing of 10 above your variable in Inspector.
Example:
Example

Note: You can use negative numbers as an argument but they can mess up the Inspector.

GUI in Scene View:

You can add GUI to the scene view via a custom inspector and Handles.BeginGUI
More about this topic here: Link to Unity Docs

Merge Scenes:

You can drag'n drop one Scene onto another to merge them.
Example:
Merge

Modify internal Components:

You can use dnSpy to modify internal Unity Engine components, copy the code and craft a new/custom one
or just have a look at how these componets work.
Here i had a look at the Terrain component:
Terrain

You can get dnSpy from here: GitHub

Break Points:

You can pause the Editor at a specific moment during runtime:
EditorApplication.isPaused = true

Follow GameObject in Scene:

Track a moving GameObject in the scene view at runtime by double tap F with the cursor inside the scene window

Hide Standard Tools:

You can use Tools.hidden = true to hide the standard tools in editor if you want to create your own.
You might also look here: Link to Unity Docs

Snapping:

You can hold Ctrl while moving an object to snap it in full world unit intervals.
This can be extremely helpful when working with modular assets.

Hide Public Variables in Inspector:

You can hide public Variables in the inspector by adding [HideInInspector] in front of them.
Example:

[HideInInspector]
public int hiddenNumber = 20;

Rename without Value loss:

For example you want to rename an array of GameObjects but dont want to reassign all the GameObjects again
you can add [FormerlySerializedAs("oldArrayName")] in front of the new Array decleration.

Scene View to Camera View:

Select the Camera and then navigate to Game Object -> Align with View
Also if you want to set the Scene View to the View of the Camera you would
also select the Camera and navigate to Game Object -> Align View to Selected

Project Search Filter:

You can filter the results of your projects by using t:type
For Example t:scene would only list all the scenes in your project.

Fullscreen!

You can expand any Unity panel to fullscreem with Shift+Space