Modify Naming Rules

July 8, 2020

·

Prefixed

While the Unrealistic Style Guide will cover the naming of most standard Engine assets, it does not handle project- or plugin-specific assets. Fortunately, Prefixed allows you to easily define your own asset naming rules or tweak pre-existing rules to fit your needs.

Sample rule set

You can define as many or as few rules as you would like in .prefix files, which should use JSON format.

Required Elements of a Rule

The two required elements for a rule are a class and a prefix.

Class

The class is the type of asset that we want to define a rule for. For C++ classes, use the core class name without any modifiers. For example:

  • UStaticMesh -> StaticMesh
  • APlayerController -> PlayerController

For Blueprint classes, just use the full class name as it appears in Editor.

Prefix

The prefix is usually a short combination of letters that hints at the type of asset it represents. For example:

  • StaticMesh -> SM_
  • PlayerController -> PC_

Prefixed does not prevent you from defining rules with conflicting or overlapping prefixes. It is up to you to make sure that each asset type has a unique prefix.

Optional Elements of a Rule

There are also several optional elements for a rule, including suffix and fields for deprecated modifiers.

Suffix

The suffix is optional. It should not be used as a substitute for a unique asset type prefix. Instead, it should be used to clarify sub-types of an asset type. For example, all Textures should have the same prefix (e.g. T_), but depending on the type of texture it is (diffuse, alpha, metallic, etc.) it should have an appropriate suffix (e.g. _D, _A, _M, etc.).

Deprecated Modifiers

The dep_prefixes and dep_suffixes fields, which should be arrays of strings, may be used to specify prefixes or suffixes that have been deprecated but may still exist on your assets. For example, if all of your static meshes have the S_ prefix but should now have the SM_ prefix, you can indicate this in the rule and the linter will automatically pull out the deprecated prefix when renaming.

Example: Character

Below is what the rule would look like if you wanted subclasses of Character to have the prefix CH_.

{
  "class": "Character",
  "prefix": "CH_",
  "dep_prefixes": [
    "Char_",
    "CHAR_"
  ]
}

Overriding Rules

Keep in mind that newer rules will override older rules. This means that even if you have Engine-wide rule that Character's should have a CH_ prefix, you can override that in a project rule file that sets the prefix to CHAR_.

Hot Reloading

You do not need to restart the Editor every time you add, delete, or modify a naming rule. Prefixed detects these changes and prompts you to reload the rule set.

The rule hot reload prompt

Click the option to Update Rule Set to bring the Editor rule set up to date.



© 2021 Mustafa Moiz.