Access Transformers

UE-CSS 4.25.3 build 42 adds a new feature: the ability to make accessors for fields, add friend classes, and make properties BlueprintReadWrite without modifying the game headers.

This ability, called the Access Transformer system, is beneficial because it allows you to essentially make header accessor edits without the cost of having to deal with merge conflicts when bringing in updated SML and game headers later down the line. It also makes it easier to collaborate with other developers, because normal header edits are made in files outside of the plugin directory, meaning they would not be included in plugin (mod) source code repositories. Access transformers are defined in a file within the plugin directory, so they can easily be included in repositories.

Config File

In order to use Access Transformers, create a file in YourPluginModReference\Config, named AccessTransformers.ini with the following format:

[AccessTransformers]
Friend=(Class="AFGSomeClass", FriendClass="UMyClass")
Accessor=(Class="AFGSomeClass", Property="mSomeProperty")
BlueprintReadWrite=(Class="AFGSomeClass", Property="mSomeProperty")

You can have multiple (or none) of each of the access transformer types (friend, accessor, and BlueprintReadWrite), but they should all be under the same [AccessTransformers] section header.

After making changes in this file, you still have to build for Development for the properties you made BlueprintReadWrite to show up in the editor.

Definitions

Friend

Adds friend class UMyClass; into the class you specify, allowing UMyClass to access all private fields and methods of AFGSomeClass.

Accessor

Creates the public methods FORCEINLINE PropertyType GetSomeProperty() { return mSomeProperty; } and FORCEINLINE void SetSomeProperty(PropertyType SomeProperty) { mSomeProperty = SomeProperty; }.

This is beneficial when you are trying to access a field and you are not in a class to use Friend for. Below is an example from PowerSuit for the FEquipmentStats struct.

// Instead of this ...
SuitCostToUse = Parent->EquipmentParent->mCostToUse;
// ... use ths
SuitCostToUse = Parent->EquipmentParent.GetCostToUse();

Note that the generated methods lack the m from the original property name.

BlueprintReadWrite

Adds BlueprintReadWrite to the specified UPROPERTY, allowing you to access that property from blueprints (it cannot be added to a non-UPROPERTY field). It also bypasses the private BPRW conflict check (which is compile time only, it does not affect the editor, or the game), so that no changes to the game headers are required.

Rider will not find the generated getters and setters, and will still show private fields as private for friended classes, because it completely ignores the .generated.h file in which the modified UHT generates them. Visual Studio does not have this problem. The code will still compile, but Rider will still show the accessed fields as errors.

Access Transformers can’t modify engine classes, since the UHT will not generate .generated.h files for the engine classes when using a prebuilt engine. It has not been tested if they would work on a source built engine.

Examples

Below is an example of the AccessTransformers.ini that uses each of accessor type. Some of the Friend classes are from the Area Actions mod.

[AccessTransformers]
Friend=(Class="AFGBuildableFactory", FriendClass="UAACopyBuildingsComponent")
Friend=(Class="AFGBuildableConveyorBase", FriendClass="UAACopyBuildingsComponent")
Friend=(Class="AFGBuildableConveyorBase", FriendClass="AAAClearInventories")
Friend=(Class="AFGHologram", FriendClass="UAACopyBuildingsComponent")
Accessor=(Class="AFGBuildableFactory", Property="mInventoryPotential")
BlueprintReadWrite=(Class="AFGSchematicManager", Property="mPurchasedSchematics")