== Integrating ==
=== Architecture ===
The system is structured as an Unreal plugin with two additional Unreal modules: one for the editor and one for the runtime. These modules use external libraries for the Mutable runtime, which is a standalone library with no dependencies.
{F85832, size=full}
The next diagram shows the basic folder structure of an Unreal Engine game that uses Mutable. The hierarchy only shows the relevant folders for Mutable source code.
{F85834, size=full}
The folder “source” is optional (and by default not included with all licenses) and it contains the source code of the standalone runtime and tools libraries. These are already included in the “lib” folder as precompiled binaries for each supported platform, with the required headers in the “include” folder.
=== Packaging a project ===
Mutable will be automatically linked in your game executable. It doesn't require any additional files or dynamic-link libraries. In order to package the data for your Customizable Objects, an additional folders needs to be added in your project settings. The plugin will try to do this for you, but if you need to do it manually you can add "MutableStreamedData" to the list of "Additional non-asset directories to package" in the project settings.
{F85836}
=== Engine Changes ===
In most versions of Mutable, some changes in the Unreal Engine codebase are required in order to improve the performance. These are modifications that cannot be implemented through plugins. In some platforms like Windows, Mutable will still work without the engine changes, but it may have lower performance and some editor features may be disabled, like automatic compilation of models when packaging.
The engine modifications are distributed through a patch file that you can find with every release of the plugin. They are also available in a GitHub branch of the official engine repository, as per Epic Game's rules. In order to apply the patch you can use standard tools like TODO.
=== Compilation warnings {anchor #warnings} ===
The patch with engine changes includes some helpers to try to detect if any modification is missing. If these warnings are visible it is a sign that some of the changes have not been applied, or may have been overwritten by other changes or merges.
These are for the runtime:
```
lang=c++
#define ANTICTO_MUTABLE_ENGINE_PATCH_TEXTURESTREAMING
#define ANTICTO_MUTABLE_ENGINE_PATCH_VERTEXBUFFERS
#define ANTICTO_MUTABLE_ENGINE_PATCH_MORPHTARGETVERTEX
```
These are for the editor:
```
lang=c++
#define ANTICTO_MUTABLE_ENGINE_PATCH_COOKHOOK
```
You don't have to manually use these defines but if they are not present, the plugin will show warnings at compile time.
{icon exclamation-triangle color=orange} Please note that these are just simple preprocessor defines, so they do not guarantee that the actual changes are present, but capture most error cases.
== Using Mutable from C++ {anchor #cpp} ==
== Using Mutable from Blueprint {anchor #blueprint} ==
== Performance tuning ==
=== Statistics widget ===
A good starting point to see the performance of Mutable in your game, is to use the provided statistics UMG widget. You can find it in the plugin //Content// folder with the name //UI/MutableStats//.
{F85822}
(WARNING) {icon exclamation-triangle color=orange} When using these statistics in the editor, the numbers will also capture all the instances built in all open levels, editors, and even content browser thumbnails, if enabled.
If your project is not using UMG you can access these statistics and log them or display them from the central singleton object UCustomizableObjectSystem. These are some of the relevant methods:
```
lang=cpp
// Get the singleton object. It will be created if it doesn't exist yet.
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Status)
static UCustomizableObjectSystem* GetInstance();
// Find out if the performance engine patches have been applied
UFUNCTION(BlueprintCallable, Category = Status)
bool AreEnginePatchesPresent() const;
// Find out the version of the plugin
UFUNCTION(BlueprintCallable, Category = Status)
FString GetPluginVersion() const;
// Get the number of instances built and alive.
UFUNCTION(BlueprintCallable, Category = Status)
int32 GetNumInstances() const;
// Get the number of instances waiting to be updated.
UFUNCTION(BlueprintCallable, Category = Status)
int32 GetNumPendingInstances() const;
// Get the total number of instances includingbuilt and not built.
UFUNCTION(BlueprintCallable, Category = Status)
int32 GetTotalInstances() const;
// Get the amount of memory in use for textures generated by mutable.
UFUNCTION(BlueprintCallable, Category = Status)
int64 GetTextureMemoryUsed() const;
// Return the average build/update time of an instance in ms.
UFUNCTION(BlueprintCallable, Category = Status)
int32 GetAverageBuildTime() const;
```
== Data-driven User Interfaces {anchor #datadriven} ==