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 a Model Object
  • Example Code
  • Metadata Annotations
  • Best Practices for Model Objects
  • Summary
  1. MetaForge

Model Objects

Overview

Model objects in MetaForge represent the core data structures that are used for creating custom editor windows and handling various game data configurations. By defining model objects, developers can easily create and manage metadata-driven properties that are editable within the Unreal Engine editor.

Model objects are defined as subclasses of UObject and are customized to contain specific properties that you want to expose and modify within the editor. These objects are essential for integrating MetaForge into your game development workflow.

Defining a Model Object

To define a model object, follow these steps:

  1. Create a new C++ class that inherits from UObject and implements the IDataModel interface.

  2. Add metadata-driven properties to the class, which will be exposed and editable within the Unreal Engine editor.

  3. Use Unreal's UPROPERTY system to mark properties for editing and serialization.

Example Code

Here is an example of defining a model object:

#pragma once

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

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

public:
    virtual FName GetModelId() override {
        return IdProperty;
    }

    UPROPERTY(EditAnywhere, Category = "MyModel", meta = (Component = "SNameProperty"))
    FName IdProperty;

    UPROPERTY(EditAnywhere, Category = "MyModel", meta = (Component = "SFloatProperty"))
    float ValueProperty;
};

In this example:

  • UMyModelObject is the model object that inherits from UObject and IDataModel.

  • IdProperty is an identifier for the model, exposed to the editor.

  • ValueProperty is another editable property, allowing users to modify its value in the editor.

Metadata Annotations

Metadata annotations are used to customize how properties are displayed and edited within the editor. In the above example, meta = (Component = "SNameProperty") specifies that the IdProperty should use a particular editor component for visualization and editing.

Common metadata annotations include:

  • Component: Specifies the editor component used for visualization (e.g., SNameProperty, SFloatProperty).

  • If: Specifies a condition for displaying the property (e.g., If = "Condition").

  • Validator: Specifies a function to validate the property's value (e.g., Validator = "UFUNCTION_NAME").

Best Practices for Model Objects

  • Keep It Simple: Only include properties that need to be exposed and modified within the editor. Avoid overcomplicating model objects with unnecessary logic.

  • Use Meaningful Categories: Use the Category specifier to group related properties logically, making it easier for users to navigate within the editor.

  • Leverage Metadata Annotations: Use metadata annotations to enhance the user experience when interacting with model objects in the editor.

Summary

Model objects are the foundation for creating configurable data structures in MetaForge. By defining model objects and applying appropriate metadata annotations, developers can create intuitive editor interfaces to manage game data efficiently.

PreviousProject ConfigurationNextModel Managers

Last updated 6 months ago