Unrealistic Style Guide

A practical set of style conventions for assets, code, and other things in Unreal Engine 4.

Preface

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."

Rebecca Murphey

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.)

Linter

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).

Discussion

To discuss this style guide, add a comment to the dedicated page on Unrealistic.dev.

Structure

There are three main buckets that Unreal Engine 4 content falls into:

  1. Assets - Anything that has a .uasset extension.
  2. Code - Anything that has a .cpp, .h, or .cs extension.
  3. Projects - Everything else.

This guide will approach styling using this basic structure.

Assets

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 .uasset extension.

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:

  1. Prefix
  2. Base
  3. Variant
  4. Suffix

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 Amena (e.g. P_Amena_Explosion, T_Amena_Eyes, etc.).

A variant is used to identify a subset of a base. For example, skeletal mesh skins of the character Amena might be SKM_Amena_Summer, SKM_Amena_Sand, SKM_Amena_BeachParty, etc. Generic variants should be named using two digits. For example, SM_Tree_01, SM_Tree_02, SM_Tree_03, etc.

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.

1.3.1 Blueprints
Asset TypePrefixSuffixNotes
Blueprint (Objects)BP_
Blueprint (Components)BPC_
Blueprint InterfaceBPI_
Blueprint Function LibraryBPFL_
Blueprint Macro LibraryBPML_
EnumerationE
StructureF

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
Asset TypePrefixSuffixNotes
ActorACT_
PawnPWN_
CharacterCH_
PlayerControllerPC_
PlayerStatePS_
GameModeBaseGM_
GameStateBaseGS_
GameInstanceGI_
1.3.3 Animations
Asset TypePrefixSuffixNotes
Animation SequenceA_
Animation CompositeAC_
Animation MontageAM_
Animation BlueprintABP_
Aim Offset 1DAO1_
Aim Offset (2D)AO2_
Blend Space 1DBS1_
Blend Space (2D)BS2_
1.3.3.1 Skeletons
Asset TypePrefixSuffixNotes
RigRIG_
SkeletonSK_
Skeletal MeshSKM_
(Skeletal) Pose AssetSKP_
(Skeletal) Physics AssetSKPH_
1.3.4 Artificial Intelligence
Asset TypePrefixSuffixNotes
AI ControllerAIC_
Behavior TreeBT_
BlackboardBB_
DecoratorBTDecorator_
ServiceBTService_
TaskBTTask_
1.3.5 Materials
Asset TypePrefixSuffixNotes
MaterialM_
Material (Decal)M__Decal
Material (Post Process)M__PP
Material (UI)M__UI
Material FunctionMF_
Material InstanceMI_
Material Parameter CollectionMPC_
1.3.6 Textures
Asset TypePrefixSuffixNotes
TextureT_
Texture (Diffuse/Albedo/Base)T__D
Texture (Normal)T__N
Texture (Roughness)T__R
Texture (Alpha/Opacity)T__A
Texture (Ambient Occlusion)T__O
Texture (Bump)T__B
Texture (Emissive)T__E
Texture (Mask)T__M
Texture (Specular)T__S
Texture CubeTC_
Media TextureMT_
Render TargetRT_
Cube Render TargetCRT_
Texture Light ProfileTLP_
1.3.6.1 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.

1.3.7 Meshes
Asset TypePrefixSuffixNotes
StaticMeshSM_
1.3.8 Particles
Asset TypePrefixSuffixNotes
Particle SystemP_
Niagara SystemNFX_
Niagara EmitterNFXE_
Niagara Effect TypeNFXET_
Niagara Dynamic Input Script (General)NFXS_
Niagara Dynamic Input Script (Function)NFXS__FN
Niagara Dynamic Input Script (Module)NFXS__MOD
Niagara Parameter CollectionNFXP_
Niagara Parameter Collection InstanceNFXPI_
1.3.9 Physics
Asset TypePrefixSuffixNotes
Physical MaterialPHYSM_
Physical Material MaskPHYSMM_
1.3.10 Sounds
Asset TypePrefixSuffixNotes
Sound CueS_
Sound WaveSW_
Sound AttenuationSATT_
Sound MixSMIX_
Sound ClassSCL_
Sound ConcurrencySCN_Should be named after corresponding Sound Class
1.3.11 User Interface
Asset TypePrefixSuffixNotes
Widget BlueprintW_
Widget Blueprint (Used In World)W__World
FontFONT_
Slate BrushSBR_
Slate Widget StyleSWS_

Code

Epic recently put out a C++ style guide. It covers most use cases and should be followed absent a compelling countervailing reason.


Copyright 2020 Mowgl33.