Menu
Lumberyard
C++ API Reference (Version 1.10)

You use the EditContext to make class data editable in the Lumberyard editor. More...

Classes

class  ClassInfo
 Builder class that reflects class data to the edit context. More...
 
class  EnumInfo
 Builder class that reflects global enum data to the edit context. More...
 

Public Member Functions

 EditContext (SerializeContext &serializeContext)
 Initializes the edit context using the serialize context. More...
 
 ~EditContext ()
 The destructor. More...
 
template<class T >
ClassInfo Class (const char *displayName, const char *description)
 Creates a temporary object (ClassInfo) that you call functions on to add reflected classes and data to the edit context. More...
 
template<class E >
EnumInfo Enum (const char *displayName, const char *description)
 Creates a temporary object (EnumInfo) that you call functions on to add reflected global enum data to the edit context. More...
 
void RemoveClassData (SerializeContext::ClassData *classData)
 Removes the edit context reflection data that is associated with a class that is reflected to the serialize context. More...
 

Public Attributes

ClassDataListType m_classData
 A list that contains data about all classes that are reflected to the edit context. More...
 
EnumDataMapType m_enumData
 A map that contains data about all enums that are reflected to the edit context. More...
 
SerializeContextm_serializeContext
 A reference to the serialize context. More...
 

Detailed Description

You use the EditContext to make class data editable in the Lumberyard editor.

Note
Classes that reflect data to the edit context are commonly AZ::Component classes, so this description focuses on components.

To make your component's data editable in the Lumberyard editor, you must inform Lumberyard which of the component's data to expose to the editor. You do this by reflecting the component's information to the global edit context, which contains information about all classes that are editable in the Lumberyard editor. The edit context exists only when the editor is running.

To reflect your component's information to the edit context, you must add code to your component's implementation of the Reflect() function. Because the data that is reflected to the edit context must also be reflected to the serialize context, you must reflect a component's data to the SerializeContext before you reflect it to the EditContext.

The following example shows how to implement a component's Reflect() function to reflect the component's data and attributes of that data to the edit context. Note that it uses a builder pattern.

class MyComponent
{
int m_data;
void MyComponent::Reflect(AZ::ReflectContext* context) // Static function
{
if (serialize)
{
// Reflect the fields that you want to serialize.
serialize->Class<MyComponent>()
->Version(1)
->Field("DataName", &MyComponent::m_data);
AZ::EditContext* edit = serialize->GetEditContext();
if (edit)
{
// Reflect the fields that you want to be editable.
edit->Class<MyComponent>("My component","Description")
->DataElement(AZ::Edit::UIHandlers::Slider,&MyComponent::m_data,"Component data","Description")
}
}
}
};

For more information about reflecting components, see Reflecting a Component for Serialization and Editing in the Lumberyard Developer Guide.

To see real examples of reflecting to the edit context, browse the Reflect() implementations of components in lumberyard-root\dev\Gems\LmbrCentral\Code\Source.

Constructor & Destructor Documentation

◆ EditContext()

AZ::EditContext::EditContext ( SerializeContext serializeContext)

Initializes the edit context using the serialize context.

The serialize context is required because classes can only reflect data to the edit context if that data is reflected to the serialize context.

◆ ~EditContext()

AZ::EditContext::~EditContext ( )

The destructor.

Member Function Documentation

◆ Class()

template<class T >
ClassInfo AZ::EditContext::Class ( const char *  displayName,
const char *  description 
)

Creates a temporary object (ClassInfo) that you call functions on to add reflected classes and data to the edit context.

Uses a builder pattern.

Template Parameters
TThe class type to reflect. This class must already be be reflected to the SerializeContext.
Parameters
displayNameA display name for the class that is being reflected to the edit context. Although this is often the class name, it can be a different name.
descriptionA description of the class that is being reflected to the edit context.
Returns
An object that contains information about all the data that a class is reflecting to the edit context.

◆ Enum()

template<class E >
EnumInfo AZ::EditContext::Enum ( const char *  displayName,
const char *  description 
)

Creates a temporary object (EnumInfo) that you call functions on to add reflected global enum data to the edit context.

Uses a builder pattern.

Template Parameters
EThe enum type to reflect. Reflected enums must have their type information declared using AZ_TYPE_INFO_SPECIALIZE.
Parameters
displayNameA display name for the enum that is being reflected to the edit context. Although this is often the enum name, it can be a different name.
descriptionA description of the enum that is being reflected to the edit context.
Returns
An object that contains information about all the data that an enum is reflecting to the edit context.

◆ RemoveClassData()

void AZ::EditContext::RemoveClassData ( SerializeContext::ClassData classData)

Removes the edit context reflection data that is associated with a class that is reflected to the serialize context.

Parameters
classDataA pointer to the SerializeContext::ClassData class for which to remove the associated edit context reflection data.

Member Data Documentation

◆ m_classData

ClassDataListType AZ::EditContext::m_classData

A list that contains data about all classes that are reflected to the edit context.

◆ m_enumData

EnumDataMapType AZ::EditContext::m_enumData

A map that contains data about all enums that are reflected to the edit context.

◆ m_serializeContext

SerializeContext& AZ::EditContext::m_serializeContext

A reference to the serialize context.

The edit context relies on the serialize context to manage information about all reflected classes and data.


The documentation for this class was generated from the following file:
  • C:/lumberyard-root/dev/Code/Framework/AZCore/AZCore/Serialization/EditContext.h