MetaForge Documentation
Fab Store PageDiscord
  • MetaForge
    • Getting Started
    • Plugin Configuration
    • Runtime Configuration
    • Project Configuration
    • Model Objects
    • Model Managers
    • Registering Models
    • Conditionals
    • Validators
    • References
    • References (Advanced)
    • Property Drawers
    • List Properties
    • IDE File Templates
    • Runtime Usage
  • Contact Us
Powered by GitBook
On this page
  • Overview
  • Defining References
  • Example Code
  • Summary
  1. MetaForge

References

PreviousValidatorsNextReferences (Advanced)

Last updated 5 months ago

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.

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:

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

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

Reference field showing selectable options of another model type