Unity Tips For Faster Easier Game Development

unity tips

14 Unity Tips For Faster Easier Game Development

Introduction

There are tons of things you can do in Unity. Hidden gems live around almost every corner. Today we are going to enlighten you about some of the more obscure actions you can take to improve and streamline your development process. These are Unity tips you have probably never heard of.

Mute Audio

No matter how awesome your audio is, it can quickly become annoying when you spend days, weeks, even years working on a level. Hearing the same audio can become even more frustrating when you are chasing down bugs or struggling to implement a new feature. This is where the Mute Audio comes in handy. It is located in the top right of the game window. Placed so obviously, it is easy to overlook.

Hide Gizmos

Struggling to see things in your scene view? This next tip is for you. Click the Gizmo button in the top right of the scene window to disable/enable gizmos. You can even go through and selectively disable/enable the ones you want.

Do Math in the Inspector

This is one of our favorite tips. We use this all the time to quickly scale or increase values. Any of the fields in the inspector can evaluate equations. This means you do not have to figure out the math for decreasing the scale by 20%. Just multiply the current value by “.20”. Want to add 5 to a value? Just enter “+ 5”.

unity editor math

Copy/Paste Colors

Did you know you can copy and paste colors? We did not and now we use it for quickly setting up a color palette for our UIs.

unity copy paste colors

Pick Colors Outside of Unity

Want to use a color from a website or image you have on your computer? Click the eyedropper next to the color to use the color picker outside of the Editor.

unity color dropper

Gradients can be Public Fields

Speaking of colors, have you ever needed to set a gradient in the editor to manipulate through script. Well, you can do that. Great for setting status effects on players, like poisoned.

public Gradient gradient;

Create Headers to Organize the Fields in the Inspector

Notice how there is a Color Gradient header above our last field? Yep you can set custom headers to help organize your data. Just add the following line with the title you want.

[Header("Color Gradient")]

This will automatically add a space before the title. If you just want to add some space for a cleaner look you can use this line.

[Space]

Create Submenus in Layers

Have you ever had multiple types of objects that were related? For example, we have platforms that go back and forth, angles, or just one way. Well, you can clean up your layers by adding submenus. Just add the layer with the / and the sublayer, i.e., Platform/OneWay.

Create Submenus in Tags

Speaking of organizing, you can also use the same trick to organize your tags. This is a quick and easy way to organize a big project, making it ten times faster to navigate through.

Edit Multiple Objects at Once

Maybe you have used this one, but if you have not it will speed up your level design. Use CTRL, or CMD on Mac, to select multiple objects. You can add components and set values in bulk this way. Great for adding box colliders and setting rigidbody properties on similarly shaped environment objects or enemies.

Pause the Game When an Error Occurs

Having a hard time narrowing what is causing an error in your game? Turn on the error pause to freeze the game exactly where the error occurred to help narrow down what is going on.

Wait for a Coroutine to Finish

Need to run two coroutines but you need to wait for one to complete before continuing the next? You can have a coroutine wait on a second coroutine by adding it to the yield return statement.

    IEnumerator FirstCoroutine()
    {
        yield return StartCoroutine(SecondCoroutine());
    }
 
    IEnumerator SecondCoroutine()
    {
        yield return new WaitForSeconds(1f);
    }

Get a Random Boolean

You can easily get a random Boolean or trigger a random action by calling Random.value, which returns a random float between 0 and 1. Just check to see if it is greater than 0.5f. You will randomly get true and false values.

        if(Random.value > 0.5f)
        {
            //do something random
        }

Customize Unity’s Default Script Templates

Do you ever get tired of seeing the same two methods, Start() and Update(), with the same two comments when you create a script? You can modify the default template to add custom comments for documentation, custom code, or just remove the default methods. Just go to this path, replacing the Unity version with your current version.

“C:\Program Files\Unity\Hub\Editor\2020.2.4f1\Editor\Data\Resources\ScriptTemplates”

Locate the template you want to edit. The default for C# is the “C# Script-NewBehaviourScript.cs” template. On Windows, you may need to open the file in a text editor running as administrator to change the file.

Now when you create a new script it will load with the new template.

And now you are better prepared to make your own games in Unity. Thank you for stopping by. Stick around and check out more of our tutorials or posts like our piece on What is a Game Developer’s Salary. Also, leave a comment telling us what tips you have for making life easier in Unity. Was it easy to follow along? What do you want to learn next? As always check out some of our published apps below.

Leave a Comment

Your email address will not be published. Required fields are marked *