class

VisualScriptClassRegistry

Module
VisualScripting
Header
#include "VisualScripting/VisualScriptClassRegistry.h"
Namespace
Mowo

Type aliases

AliasDescription
using ActorFactory = MObject* (*)()The gameplay layer's backing-actor factory (returns new AVisualScriptActor() typed as MObject*). Every synthetic class uses it as its MClass.construct. nativeBaseClass names the class the factory actually constructs: a synthetic declaring a native parent OUTSIDE that class's ancestry would make IsChildOf lie about an object that is not that type, and every static_cast through the claim corrupts — registration checks against it.

Properties

TypeNameDescription
static constexpr uint32_tkNativeHostSlotsMClass::construct is a plain function pointer, so each hosted class owns one numbered trampoline that finds its synthetic class again. Default 512.

Constructors

SignatureNameDescription
VisualScriptClassRegistry(const VisualScriptClassRegistry&) = deleteVisualScriptClassRegistry

Public functions

ReturnsNameDescription
VisualScriptClassRegistry&Get
VisualScriptClassRegistry&operator=
voidSetActorFactory
boolHasActorFactory
voidAddBackingClassA backing class for Visual Script classes whose native parent is nativeParent or derives from it: AVisualScriptCharacter for ACharacter, AVisualScriptPawn for APawn.
FNameBackingClassOfThe backing class a registered Visual Script class spawns as.
voidSetNativeHost
boolUsesNativeHostTrue when def (parents already resolved) would be hosted on its native parent rather than a backing class.
MClass*NativeParentOfThe native MClass the root of def's Visual Script chain declares as its parent, or null when it names none that resolves.
MObject*ConstructHostedGame thread only; the registry lock is held across construction.
MClass*RegisterTake ownership of def, synthesize its MClass, and register it by name.
std::vector<std::unique_ptr<VisualScriptClass>>OrderParentsFirstOrders parsed classes so every Visual Script parent precedes its children.
std::vector<std::unique_ptr<VisualScriptClass>>LoadClassFilesParses every file once, on up to eight workers, and returns the classes that loaded with a name, in paths order (what OrderParentsFirst takes).
MClass*ReregisterHot-reload: swap the definition behind an already-registered name.
boolUnregisterDrop a registered class (removes it from MClassRegistry and frees its storage).
VisualScriptClass*FindThe VisualScriptClass behind a registered name, or nullptr.
std::vector<VisualScriptClass*>CollectClassesEvery registered definition, in registration order.
uint32_tRevisionBumped on every Register / Reregister / Unregister / Clear — lets a cache notice new classes without walking the table each frame.
voidClearDrop everything (tests / shutdown).
size_tNum
voidAddPendingLazy registration.
MClass*ResolvePending
uint32_tResolveAllPending
size_tPendingCount
uint32_tPendingParsesHow many definitions the pending path parsed from disk, ever.

Function details

VisualScriptClassRegistry

C++
VisualScriptClassRegistry(const VisualScriptClassRegistry&) = delete

Get

C++
static VisualScriptClassRegistry& Get()

operator=

C++
VisualScriptClassRegistry& operator=(const VisualScriptClassRegistry&) = delete

SetActorFactory

C++
void SetActorFactory(ActorFactory factory, FName nativeBaseClass = FName())

HasActorFactory

C++
bool HasActorFactory() const

AddBackingClass

C++
void AddBackingClass(FName nativeParent, ActorFactory factory, FName backingClass)

A backing class for Visual Script classes whose native parent is nativeParent or derives from it: AVisualScriptCharacter for ACharacter, AVisualScriptPawn for APawn. Registration picks the one nearest the declared parent up its native chain, and falls back to the SetActorFactory default; before this every Visual Script class was an AVisualScriptActor whatever it declared.

BackingClassOf

C++
FName BackingClassOf(FName visualScriptClassName) const

The backing class a registered Visual Script class spawns as.

SetNativeHost

C++
void SetNativeHost(const FNativeHost& host)

UsesNativeHost

C++
bool UsesNativeHost(const VisualScriptClass& def) const

True when def (parents already resolved) would be hosted on its native parent rather than a backing class.

NativeParentOf

C++
static MClass* NativeParentOf(const VisualScriptClass& def)

The native MClass the root of def's Visual Script chain declares as its parent, or null when it names none that resolves.

ConstructHosted

C++
MObject* ConstructHosted(uint32_t slot)

Game thread only; the registry lock is held across construction.

Register

C++
MClass* Register(std::unique_ptr<VisualScriptClass> def)

Take ownership of def, synthesize its MClass, and register it by name. Returns the synthetic MClass* (also discoverable via MClassRegistry:: FindByName), or nullptr if no factory is installed or the name is taken.

OrderParentsFirst

C++
static std::vector<std::unique_ptr<VisualScriptClass>> OrderParentsFirst(std::vector<std::unique_ptr<VisualScriptClass>> classes)

Orders parsed classes so every Visual Script parent precedes its children. Register resolves a class's Visual Script parent once, at registration, and a parent it cannot find yet reads as native — a child registered first runs without the parent's variables and graphs for the whole session. Order is otherwise kept; classes in a parent cycle, or whose parent is not in the set and not registered, follow in their original order.

LoadClassFiles

C++
static std::vector<std::unique_ptr<VisualScriptClass>> LoadClassFiles(const std::vector<std::string>& paths, std::vector<std::string>* outFailures = nullptr)

Parses every file once, on up to eight workers, and returns the classes that loaded with a name, in paths order (what OrderParentsFirst takes). A parse touches no registry, so only the registration after it has to stay on the calling thread; the editor parsed every project class serially before its first frame. A file that fails is logged and named in outFailures.

Reregister

C++
MClass* Reregister(std::unique_ptr<VisualScriptClass> def)

Hot-reload: swap the definition behind an already-registered name. The synthetic MClass instance is REUSED (its pointer is what live actors and MClassRegistry hold) — only userData / super link change; children's parentVisualScript links re-point at the new definition. Falls back to Register when the name is new. Live actors rebind lazily on their next graph dispatch, keeping variable state.

Unregister

C++
bool Unregister(FName className)

Drop a registered class (removes it from MClassRegistry and frees its storage). Returns true if found.

Find

C++
VisualScriptClass* Find(FName className) const

The VisualScriptClass behind a registered name, or nullptr.

CollectClasses

C++
std::vector<VisualScriptClass*> CollectClasses() const

Every registered definition, in registration order. The debug tooling (DAP source listing, breakpoint resolution) enumerates through this.

Revision

C++
uint32_t Revision() const

Bumped on every Register / Reregister / Unregister / Clear — lets a cache notice new classes without walking the table each frame.

Clear

C++
void Clear()

Drop everything (tests / shutdown). Unregisters each name first.

Num

C++
size_t Num() const

AddPending

C++
void AddPending(const std::string& className, const std::string& parentClassName, const std::string& path, std::unique_ptr<VisualScriptClass> parsed = nullptr)

Lazy registration. A class known by name and file (FVisualScriptClassIndex) but not registered: the first FindByName for it — a scene placing one, a spawn by class — parses (unless parsed already holds the definition) and registers it, parents first; anything enumerating classes (MClassRegistry::GetAllClasses, CollectClasses) registers every pending one first. Registering a name directly drops its pending entry. The first call installs the MClassRegistry hooks.

ResolvePending

C++
MClass* ResolvePending(FName className)

ResolveAllPending

C++
uint32_t ResolveAllPending()

PendingCount

C++
size_t PendingCount() const

PendingParses

C++
uint32_t PendingParses() const

How many definitions the pending path parsed from disk, ever.

Generated from VisualScripting/VisualScriptClassRegistry.h via visualscripting.json · Nov 5, 2026Version 1.0.0