β¨ Object Variable (Blueprint & C++)
Short Description
The UGorgeousObjectVariable class is the base class for defining variables as objects within the Gorgeous Things ecosystem. It provides a flexible and extensible way to represent variables as UObjects, supporting single, array, map, and set types.
Long Description
UGorgeousObjectVariable serves as the foundation for creating and managing variables as objects in the Gorgeous Things plugin. This class offers a structured approach to variable handling, enabling dynamic data storage, network replication, and various data organization methods.
π Features
NewObjectVariable
Constructs a new object variable and registers it within the given registry depending on the parent given.
Tip
When you set the parent to an object variable that is not the Root Object Variable, you can create a hierarchical structure. This allows you to organize and manage your variables in a tree-like fashion.
| Parameter | Type | Description | 
|---|---|---|
Class | 
TSubclassOf<UGorgeousObjectVariable> | 
The class that the object variable should derive from. | 
Parent | 
UGorgeousObjectVariable* | 
The parent of this object variable. The chain can be followed up to the root object variable. | 
bShouldPersist | 
bool | 
Weather this object variable should be persistent across level switches. | 
| Parameter | Type | Description | 
|---|---|---|
ReturnType | 
UGorgeousObjectVariable* | 
A new variable in object format. | 
Identifier | 
FGuid | 
The unique identifier of the object variable. | 
Important
Ensure that the Class is valid before calling this function. Registering a null or invalid class can lead to unexpected behavior and potential crashes.
Important
Ensure that the Parent pointer is valid before calling this function. Registering a null or invalid pointer can lead to unexpected behavior and potential crashes.
UGorgeousRootObjectVariable* RootObjectVariable = UGorgeousRootObjectVariable::GetRootObjectVariable();
FGuid MyNewObjectVariableIdentifier;
UGorgeousObjectVariable* MyNewObjectVariable = RootObjectVariable->NewObjectVariable(UString_SOV::StaticClass(), MyNewObjectVariableIdentifier, nullptr, false);
InstantiateTransactionalObjectVariable
Instantiates a new object variable of the specified class as transactional and registers it as a child of the given Parent for persistence across editor sessions.
| Parameter | Type | Description | 
|---|---|---|
Class | 
TSubclassOf<UGorgeousObjectVariable> | 
The class of the object variable to instantiate. | 
Parent | 
UGorgeousObjectVariable* | 
The parent of the new instance. | 
| Parameter | Type | Description | 
|---|---|---|
ReturnType | 
UGorgeousObjectVariable | 
The new transactional instance. | 
Important
Ensure that the Class is valid before calling this function. Registering a null or invalid class can lead to unexpected behavior and potential crashes.
Important
Ensure that the Parent pointer is valid before calling this function. Registering a null or invalid pointer can lead to unexpected behavior and potential crashes.
InvokeInstancedFunctionality
Invokes the instanced functionality for when the ObjectVariable is contained inside a UPROPERTY with the Instanced meta specifier.
| Parameter | Type | Description | 
|---|---|---|
NewUniqueIdentifier | 
FGuid | 
The new unique identifier. | 
RegisterWithRegistry
Registers the object variable with the Gorgeous Core registry. This crucial step ensures that the variable is tracked and managed by the system, allowing it to participate in the Gorgeous Things ecosystem's functionality.
Usage
This function is typically called internally by the system when a new UGorgeousObjectVariable is created. However, you might need to call it manually in specific scenarios, such as when re-registering a variable after a specific event.
| Parameter | Type | Description | 
|---|---|---|
NewObjectVariable | 
TObjectPtr<UGorgeousObjectVariable> | 
A pointer to the object variable instance that needs to be registered. | 
Important
Ensure that the NewObjectVariable pointer is valid before calling this function. Registering a null or invalid pointer can lead to unexpected behavior and potential crashes.
SetParent
Sets the parent of this object variable. Object variables can be organized in a hierarchy, and this function establishes the parent-child relationship.
| Parameter | Type | Description | 
|---|---|---|
NewParent | 
UGorgeousObjectVariable* | 
The new parent of the object variable. | 
Important
Ensure that the NewParent pointer is valid before calling this function. Registering a null or invalid pointer can lead to unexpected behavior and potential crashes.
SetDynamicProperty
Constructs a new object variable and registers it within the given registry depending on the parent given.
| Parameter | Description | 
|---|---|
InTCppType | 
The C++ type of the property. | 
TInPropertyBaseClass | 
The base class of the property. | 
| Parameter | Type | Description | 
|---|---|---|
PropertyName | 
FName | 
The name of the property to set. | 
Value | 
InTCppType* | 
The value to set. | 
GetDynamicProperty
Gets a dynamic property of the object variable at runtime. This function retrieves the value of a property at runtime.
| Parameter | Description | 
|---|---|
InTCppType | 
The C++ type of the property. | 
TInPropertyBaseClass | 
The base class of the property. | 
| Parameter | Type | Description | 
|---|---|---|
PropertyName | 
FName | 
The name of the property to get. | 
| Parameter | Type | Description | 
|---|---|---|
ReturnType | 
bool | 
True if the property was successfully retrieved, false otherwise. | 
OutValue | 
InTCppType | 
The output value of the property. | 
Variable Properties
| Property | Type | Description | 
|---|---|---|
UniqueIdentifier | 
FGuid | 
A unique identifier for the object variable. | 
VariableRegistry | 
TArray<TObjectPtr<UGorgeousObjectVariable>> | 
The registry of child object variables. | 
bPersistent | 
bool | 
Indicates whether the variable persists across level transitions. | 
Parent | 
UGorgeousObjectVariable* | 
The parent object variable in the hierarchy. | 
Abstract
The UE_DEFINE_OBJECT_VARIABLE_*_INTERFACE and UE_DECLARE_OBJECT_VARIABLE_DEFAULT_*_IMPLEMENTATION macros are used to automatically generate getter and setter functions for various variable types (single, array, map, set). They simplify the process of defining how object variables interact with different data types.