A practical set of style conventions for assets, code, and other things in Unreal Engine 4.
In the developer universe, there is an oft-cited mantra that there is no such thing as "good" or "bad" style. Instead, it has been said:
"Arguments over style are pointless. There should be a style guide, and you should follow it."
I disagree. Having come from a legal background, I can say with certainty that there is such a thing as good and bad style, just as there is good and bad writing. Indeed, quality lawyers spend their working lives trying to become better writers (until they become judges, at which point all writing skill and common sense goes out the window).
There are sentences, words, and formats that convey meaning well, and then there are sentences, words, and formats that obfuscate, confuse, and mislead. The same can be said for software development. After all, the end user is the same in each domain: human. As humans building for other humans (including ourselves), the empathetic thing to do is to maintain good style to the extent we can.
With that said, the following style rules are designed as a lowest common denominator. Each project, like each essay or brief, will have its own unique classes and logical structure that defy one-size-fits-all classification. However, each project should strive to follow these basic guidelines. (Thanks are due to Michael Allar for creating the Gamemakin UE4 Style Guide, which served as the inspiration for this style guide.)
There is an Editor plugin available on the Marketplace that allows you to easily enforce the asset styling conventions in this guide (or to edit those conventions to fit your needs).
To discuss this style guide, add a comment to the dedicated page on Unrealistic.dev.
There are three main buckets that Unreal Engine 4 content falls into:
- Assets - Anything that has a
- Code - Anything that has a
- Projects - Everything else.
This guide will approach styling using this basic structure.
An 'asset' can mean many things in many contexts. In Unreal Engine 4, and for purposes of this guide, an asset means any file that has a
1.1 A Rule for Every Asset, and Every Asset Following Its Rule
This guide provides rules for many of the standard asset types. However, there is no way it can account for game- or project-specific assets (e.g. projectiles, quests, etc.). This does not mean that you should not establish rules for those assets yourself.
As new asset types get added to your project, define corresponding naming conventions for those asset types and enforce them.
1.2 Naming Format
The name of an asset is made up of four elements:
A prefix is typically a combination of letters that hints at the asset type. For example,
SM_ is used for
StaticMesh. With the exception of Blueprint Enumerations and Structures, every prefix should include an underscore (
_). Every asset should have a prefix.
The base is the locus of the asset. For example, assets related to the character Amena would have the base
A variant is used to identify a subset of a base. For example, skeletal mesh skins of the character Amena might be
SKM_Amena_BeachParty, etc. Generic variants should be named using two digits. For example,
A suffix is used to identify a subset of an asset type. Certain assets, such as Textures, will have various sub-types (e.g. diffuse, normal, alpha) which are not reflected in the prefix and which cannot otherwise be determined without opening up the asset itself. In these limited circumstances, a suffix can help to provide further context in a consistent way. A suffix is not a substitute for a prefix. Most assets will not have a suffix.
1.2.1 Spacing and Casing
Asset names should not have spaces. Asset names should not have underscores, except for prefixes and suffixes. Bases and variants should be in PascalCase.
1.3 Naming Conventions
Pair the base and variant of your asset with the following modifiers to calculate the final name for your asset.
|Blueprint Function Library||BPFL_|
|Blueprint Macro Library||BPML_|
Many assets come with Blueprint scripting - Objects, Actors, Widgets, etc. This has led to the unfortunate practice of using the
BP_ prefix with anything that incorporates Blueprint scripting. In turn, this results in a Content directory full of
BP_ prefixed assets, with no way to tell what each one is without looking at the thumbnail or opening the asset.
We can do better than that. Only apply the
BP_ prefix to Object Blueprints. Do not apply the prefix to:
- Actors or Actor subclasses
- Widget Blueprints
- Animation Blueprints
- Anything else
1.3.2 Gameplay Core
|Aim Offset 1D||AO1_|
|Aim Offset (2D)||AO2_|
|Blend Space 1D||BS1_|
|Blend Space (2D)||BS2_|
|(Skeletal) Pose Asset||SKP_|
|(Skeletal) Physics Asset||SKPH_|
1.3.4 Artificial Intelligence
|Material (Post Process)||M_||_PP|
|Material Parameter Collection||MPC_|
|Texture (Ambient Occlusion)||T_||_O|
|Cube Render Target||CRT_|
|Texture Light Profile||TLP_|
18.104.22.168 Texture Packing
From the Gamemakin LLC style guide:
It is common practice to pack multiple layers of texture data into one texture. An example of this is packing Emissive, Roughness, Ambient Occlusion together as the Red, Green, and Blue channels of a texture respectively. To determine the suffix, simply stack the given suffix letters from above together, e.g. _ERO.
It is generally acceptable to include an Alpha/Opacity layer in your Diffuse/Albedo's alpha channel and as this is common practice, adding A to the _D suffix is optional.
Packing 4 channels of data into a texture (RGBA) is not recommended except for an Alpha/Opacity mask in the Diffuse/Albedo's alpha channel as a texture with an alpha channel incurs more overhead than one without.
|Niagara Effect Type||NFXET_|
|Niagara Dynamic Input Script (General)||NFXS_|
|Niagara Dynamic Input Script (Function)||NFXS_||_FN|
|Niagara Dynamic Input Script (Module)||NFXS_||_MOD|
|Niagara Parameter Collection||NFXP_|
|Niagara Parameter Collection Instance||NFXPI_|
|Physical Material Mask||PHYSMM_|
|Sound Concurrency||SCN_||Should be named after corresponding Sound Class|
1.3.11 User Interface
|Widget Blueprint (Used In World)||W_||_World|
|Slate Widget Style||SWS_|
Epic recently put out a C++ style guide. It covers most use cases and should be followed absent a compelling countervailing reason.