> For the complete documentation index, see [llms.txt](https://rockon-games.gitbook.io/metaforge-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rockon-games.gitbook.io/metaforge-documentation/readme/references.md).

# References

## Overview

References in MetaForge provide a way to establish relationships between different model objects. By using references, developers can link data together, making it easier to create interconnected models and implement complex game data structures in the Unreal Engine editor. References allow you to point from one model object to another, providing a flexible and reusable approach to managing game assets.

<figure><img src="/files/tKluvBdABLJLsa9nBkHa" alt=""><figcaption><p>Reference field showing selectable options of another model type</p></figcaption></figure>

## Defining References

References in MetaForge work by defining a property to hold the ID of the referenced model. You can use the `UPROPERTY` macro to define the reference, specifying the metadata to configure how the reference works.

### Example Code

Here is an example of defining a reference in a model object:

```cpp
#pragma once

#include "CoreMinimal.h"
#include "UDataModel.h"
#include "UMyReferencedModel.generated.h"

UCLASS()
class UMyReferencedModel : public UObject, public IDataModel
{
    GENERATED_BODY()

public:
    UPROPERTY(EditAnywhere, meta = (Component="SReferenceProperty", LoadFunction="GetReferences"), Category = "Stat")
    FName* MyOtherObjectReference;

    UFUNCTION()
    TArray<MyOtherObject*> GetReferences() const;
};
```

In this example:

* **`MyOtherObjectReference`** holds the ID of the referenced model.&#x20;
* **`LoadFunction`** is a `UFUNCTION()` defined on the model object that returns a `TArray` of `IDataModel`-derived object pointers.
* References only work for objects that are derived from `UObject` and `IDataModel`.

## Summary

References are a powerful feature in MetaForge that allow you to create relationships between model objects. By using references, you can build complex and interconnected data structures while maintaining flexibility and reusability. Whether you need strong or weak references, MetaForge provides the tools to manage these relationships effectively within the Unreal Engine editor.
