#include <ComponentAdapter.h>
Inherits AZ::Component.
Public Member Functions | |
AZ_RTTI ((ComponentAdapter, "{644A9187-4FDB-42C1-9D59-DD75304B551A}", TController, TConfiguration), AZ::Component) | |
ComponentAdapter (const TConfiguration &configuration) | |
void | Init () override |
void | Activate () override |
void | Deactivate () override |
Protected Member Functions | |
bool | ReadInConfig (const AZ::ComponentConfig *baseConfig) override |
bool | WriteOutConfig (AZ::ComponentConfig *outBaseConfig) const override |
Static Protected Member Functions | |
static void | Reflect (AZ::ReflectContext *context) |
Protected Attributes | |
TController | m_controller |
ComponentAdapter is a utility base class that provides a consistent pattern for implementing components that operate in the launcher but may need to share code in different contexts like the editor.
ComponentAdapter achieves this by delegating to a controller class that implements common behavior instead of duplicating code between multiple components.
To use the ComponentAdapter, 2 classes are required for the template:
The concrete component extends the adapter and implements behavior which is unique to the component.
TController can handle any common functionality between the runtime and editor component and is where most of the code for the component will live
TConfiguration is where any data that needs to be serialized out should live.
TController must implement certain functions to conform to the template. These functions mirror those in AZ::Component and must be accesible to any adapter that follows this pattern:
In addition, certain functions will optionally be called if they are available:
It is recommended that TController handle the SerializeContext, but the editor components handle the EditContext. TController can friend itself to the editor component to make this work if required.