I hope that you are having a wonderful holiday season and that you get some time to relax/spend time with those who matter most to you, even if it is over a Zoom call.

I’m sure you’ve got a lot going on right now as we close out this year, so I am going to keep this week’s Feature Friday brief. And I can tell you that this week’s feature will save you a ton of time when you are developing.

This week we are going to be talking about Presets. Using Presets, we can save configuration values as an asset to quickly set all the values on a given component. There isn’t much too them once you know the basics so today we’ll be going over:

  • What are Presets?
  • How to Use Presets
  • Using Presets to Set Default Component Values

And per usual, I’ll be featuring a game, asset, or video tutorial made with the Unity game engine. This week I’ll be featuring a game you can play with your friends and family this holiday season, so make sure you read to the end!

1. What are Presets?

To put simply, Presets are a way that we can store the values for components as an asset.

But why would you want to do this?

For one, this makes it so you can easily share component values between many instances of a component. If you made a custom script that has many values you can save the values into a Preset asset that appears in the project hierarchy.

This Preset asset then can be dragged onto a component and it will set all the values that were saved in that Preset. This means that there is no more guessing or checking multiple locations to make sure the values are set correctly.

Another benefit is that you can have variations of these Presets. If you had an Enemy Controller component, you could save multiple Presets for different variants – you could store values for a slow enemy, strong enemy, smart enemy, and so on.

The last major benefit of Presets is that you can use a Preset as the default values for a component.

Have you ever used the “reset” option on a Transform component to set the GameObject back to the origin? Well this is Presets at work.

You’ll see how all values are reset: The position and rotation are set to (0, 0, 0) and the scale is set to (1, 1, 1) – no matter what it was set to before.

Well with Presets we can take that a step further and use one of our custom Presets as the new default. So if you wanted, you could create a Transform preset setting the position to (5, 8, 0), rotation to (90, 45, 35), and scale to (2, 2, 1). Then any time you reset the transform component of any GameObject, it will be set to those values.

So now that you know some of the use cases, let me show you just how easy they are to use.

2. How to Use Presets?

On every component, there is a little icon in the upper right that opens the Presets window.

The Presets window shows you all the available Presets for that specific component. If you’re just starting to use Presets, you won’t see any available Presets.

To create a Preset, just click “Save Current to…” and a dialog popup opens up prompting you to save the Preset somewhere and set a name for the .asset file.

And that’s it, you’ve just saved your first Preset!

Now the next time you open the Presets window on the for that type of component, you’ll see the Preset you just saved; and you can double click on it to load those values into that component.

You can also locate the Preset asset file in the project hierarchy and drag it onto the component.

One thing you should keep in mind with Presets is that they aren’t linked to the component once the values are set. You can think of using Presets as like copying and pasting values – once they’re set, if you change the values on the Preset asset, they will not change the component values the Preset was set to.

3. Using Presets to Set Default Component Values

Once you’ve created a few Presets, if you want, you can now set one of them as the default values for a component.

There are a few ways to do this. If you know where the Preset asset is in the Hierarchy you can open it up in the inspector and then click on the “Add to <Component> Default.”

Doing this will set the default values of that component, so pressing the Reset button component will set the values of the component to that Preset.

You can also manage the Preset defaults through the Preset Manager. Just open up the Project Settings and there is a tab for Preset Manager.

Here you can manage all the Preset defaults and set some more specific parameters. If you are interested in learning more about the Presets Manager, check out the Unity documentation here: https://docs.unity3d.com/Manual/class-PresetManager.html

And if you still haven’t had enough of Presets, here is some more information on how you can setup you custom scripts to be used with Presets – https://docs.unity3d.com/Manual/SupportingPresets.html

Featured Unity Game of the Week

As promised this week I am featuring a game you can play with the whole family, even better there is also a fantastic sequel to the original hit.

The game I am talking about is Overcooked and the sequel Overcooked 2!

Overcooked is a local multiplayer game that puts your friends/family in charge of running the kitchen of a restaurant.

Guests will come in wanting different orders off the menu and it’s your job to make the dish to their liking. Each dish requires a number of steps to complete and you’ll need to work together if you want to prepare the dishes on time.

Hilarity ensues as everyone starts running into each other, dropping food, and letting things burn. It will surely bring some laughs and friendly competition to your household this holiday season.

Go watch the trailer for Overcooked 2 here:

Anyways, I’ll leave you back to your holiday plans. I do hope that you enjoy yourself, and if you do get an opportunity, keep on creating!

-Johnny Thompson
Turbo Makes Games