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 Manager
  • Example Code
  • Responsibilities of a Model Manager
  • Best Practices for Model Managers
  • Summary
  1. MetaForge

Model Managers

Overview

Model managers in MetaForge are responsible for managing collections of model objects. They provide functionality to create, edit, serialize, and deserialize model objects, making it easier to handle game data configurations within the Unreal Engine editor. Model managers serve as a bridge between individual model objects and the editor interface, allowing for seamless integration of data management.

Model managers are defined as subclasses of UObject and typically extend the BaseModelManager class, providing specific functionality for the types of model objects they manage.

Defining a Model Manager

To define a model manager, follow these steps:

  1. Create a new C++ class that inherits from BaseModelManager and implements the desired functionality for managing a collection of model objects.

  2. Override the necessary methods to provide custom behavior for creating and accessing model objects.

Example Code

Here is an example of defining a model manager:

#pragma once

#include "CoreMinimal.h"
#include "UMyModelObject.h"
#include "Data/BaseModelManager.h"
#include "UMyModelManager.generated.h"

UCLASS(Blueprintable, BlueprintType)
class UMyModelManager : public UObject, public BaseModelManager<UMyModelObject, UMyModelManager>
{
    GENERATED_BODY()

protected:
    virtual TArray<UObject*>& GetObjectsMutable() override {
        return reinterpret_cast<TArray<UObject*>&>(ModelObjects);
    }
    virtual UMyModelObject* CreateNewObject() const override {
        UMyModelObject* newObj = NewObject<UMyModelObject>();
        newObj->IdProperty = FName("Default Name");
        return newObj;
    }

    UPROPERTY(Instanced)
    TArray<UMyModelObject*> ModelObjects;
};

In this example:

  • UMyModelManager is the model manager that inherits from BaseModelManager and manages instances of UMyModelObject.

  • GetObjectsMutable() returns a mutable reference to the collection of model objects, allowing the manager to modify the collection.

  • CreateNewObject() is responsible for creating new instances of UMyModelObject and initializing them.

Responsibilities of a Model Manager

Model managers handle the following responsibilities:

  • Object Creation: Creating new instances of model objects and initializing their properties.

  • Serialization and Deserialization: Saving and loading model objects to and from disk, ensuring data persistence between editor sessions.

  • Editing and Access: Providing functions to add, remove, or modify model objects within the collection.

Best Practices for Model Managers

  • Singleton Pattern: Use a singleton pattern for model managers to ensure there is only one instance managing a particular set of model objects. Model Managers inheriting from BaseModelManager already implement this pattern.

Summary

Model managers are crucial for effectively managing collections of model objects within MetaForge. By centralizing the creation, editing, and serialization of model objects, model managers simplify the process of managing complex game data configurations in Unreal Engine.

PreviousModel ObjectsNextRegistering Models

Last updated 6 months ago