Auto Preset enables scriptable configuration of assets from the Unity Editor without requiring any additional code.
AutoPresetConfig
is a simple Scriptable Object derived class that holds a reference to a native Unity Preset
asset; these assets can be created from any native Unity asset or component, containing the serialized settings of that asset in a dedicated Scriptable Object. Any asset imported in the same folder as a AutoPresetConfig
asset(s) will check to see if any of them apply to that type of asset. If they do, the first applicable AutoPresetConfig
asset found will automatically be applied to that newly imported asset.
Using this library in your project can be done in three ways:
The package is available on the openupm registry. It's recommended to install it via openupm-cli.
openupm add com.jeffcampbellmakesgames.autopresets
Using the native Unity Package Manager introduced in 2017.2, you can add this library as a package by modifying your manifest.json
file found at /ProjectName/Packages/manifest.json
to include it as a dependency. See the example below on how to reference it.
{
"dependencies": {
...
"com.jeffcampbellmakesgames.autopresets" : "https://github.com/jeffcampbellmakesgames/unity-auto-preset.git#release/stable",
...
}
}
The latest release can be found here as a UnityPackage file that can be downloaded and imported directly into your project's Assets folder.
This type of automatic, scriptable configuration of assets can be used to reduce the boilerplate, often tedious work of configuring newly imported assets and can prevent errors from doing so manually.
For example, a group of textures may require specific compression settings and properties in order to be rendered without artifacts by a shader. This may require manual tweaking to elicit what those settings are and apply them manually from that point on, requiring time and energy to make sure all of the settings are correct for any new textures and inviting human error.
Instead, follow these steps to have those settings applied automatically every time a texture is imported into a specific folder.
- Configure one texture using the proper settings and save those settings as a
Preset
by clicking the dial icon at the top right of its inspector. This allows you to save those settings as aPreset
.
- Create a
AutoPresetConfig
asset in that folder by right-clicking on the folder in the project view and selectingCreate=>JCMG=>AutoPreset=>AutoPresetConfig
and give it an appropriate name.
- Assign that newly created
Preset
asset to theAutoPresetConfig
in its inspector.
It may be convenient at times to update a Preset
and apply any changes made to any assets that would be affected by it manually. There are two ways to do this:
- Right-click the
Preset
and select the menu-itemAutoPresets=>Reimport linked assets
. This will find anyAutoPresetConfig
instances in the project that reference thatPreset
and reimport any applicable assets. - Select a specific
AutoPresetConfig
asset in the project and select theReimport linked assets
button underneathActions
. This will reimport any applicable assets in the same folder.
You can use AutoPresets to automatically configure any of the supported asset types below:
- Textures
- AudioClips
- Materials
- Cubemaps
- Animations
- Assemblies/Plugins
- Models
- SpeedTree
- Any other Unity or custom assets that can generate a
Preset
.
If you find any bugs or if there is a new feature you desire, please create a new issue here or add your comments/thoughts to a related existing issue. If you are interested in contributing a PR for either of these types of issues, read the contribution guidelines here first and please do so!
If this is useful to you and/or you’d like to see future development and more tools in the future, please consider supporting it either by contributing to the Github projects (submitting bug reports or features,pull requests) or by buying me coffee using any of the links below. Every little bit helps!