Open 3D Engine AzToolsFramework API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzToolsFramework::Components::EditorComponentBase Class Reference

#include <EditorComponentBase.h>

Inherits AZ::Component.

Inherited by AzToolsFramework::Components::EditorComponentAdapter< TController, TRuntimeComponent, TConfiguration >, AzToolsFramework::Components::EditorDisabledCompositionComponent, AzToolsFramework::Components::EditorEntityIconComponent, AzToolsFramework::Components::EditorEntitySortComponent, AzToolsFramework::Components::EditorInspectorComponent, AzToolsFramework::Components::EditorLockComponent, AzToolsFramework::Components::EditorNonUniformScaleComponent, AzToolsFramework::Components::EditorOnlyEntityComponent, AzToolsFramework::Components::EditorPendingCompositionComponent, AzToolsFramework::Components::EditorVisibilityComponent, AzToolsFramework::Components::GenericComponentWrapper, AzToolsFramework::Components::ScriptEditorComponent, AzToolsFramework::Components::SelectionComponent, AzToolsFramework::Components::TransformComponent, AzToolsFramework::Layers::EditorLayerComponent, AzToolsFramework::LocalViewBookmarkComponent, AzToolsFramework::Prefab::EditorPrefabComponent, and AzToolsFramework::SharedViewBookmarkComponent.

Public Member Functions

 AZ_RTTI (EditorComponentBase, "{D5346BD4-7F20-444E-B370-327ACD03D4A0}", AZ::Component)
 
 EditorComponentBase ()
 
void SetDirty ()
 
virtual void Init () override
 
virtual void Activate () override
 
virtual void Deactivate () override
 
void OnAfterEntitySet () override final
 
void SetSerializedIdentifier (AZStd::string serializedIdentifier) override final
 
AZStd::string GetSerializedIdentifier () const override final
 
AZ::TransformInterface * GetTransform () const
 
AZ::Transform GetWorldTM () const
 
AZ::Transform GetLocalTM () const
 
bool IsSelected () const
 
virtual void BuildGameEntity (AZ::Entity *)
 
virtual void SetPrimaryAsset (const AZ::Data::AssetId &)
 
virtual void AddContextMenuActions (QMenu *)
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Friends

class EditorEntityActionComponent
 
class EditorDisabledCompositionComponent
 
class EditorPendingCompositionComponent
 

Detailed Description

A base class for all editor components. Derive from this class to create a version of a component to use in the editor, as opposed to the version of the component that is used during runtime.

Important: Game components must not inherit from EditorComponentBase. To create one or more game components to represent your editor component in runtime, use BuildGameEntity().

To learn more about editor components, see the Editor Components documentation.

Constructor & Destructor Documentation

◆ EditorComponentBase()

AzToolsFramework::Components::EditorComponentBase::EditorComponentBase ( )

Creates an instance of this class.

Member Function Documentation

◆ Activate()

virtual void AzToolsFramework::Components::EditorComponentBase::Activate ( )
overridevirtual

Gets the transform component and selection component of the entity that the component belongs to, if the entity has them. Overrides AZ::Component::Activate().

Important: Components derived from EditorComponentBase must call the Activate() function of the base class.

Reimplemented in AzToolsFramework::Components::EditorComponentAdapter< TController, TRuntimeComponent, TConfiguration >, AzToolsFramework::Layers::EditorLayerComponent, AzToolsFramework::Components::EditorNonUniformScaleComponent, AzToolsFramework::Components::GenericComponentWrapper, AzToolsFramework::Components::ScriptEditorComponent, and AzToolsFramework::Components::TransformComponent.

◆ AddContextMenuActions()

virtual void AzToolsFramework::Components::EditorComponentBase::AddContextMenuActions ( QMenu *  )
inlinevirtual

Implement this to add component specific context menu options to your editor component when right clicked in the entity inspector

◆ AZ_RTTI()

AzToolsFramework::Components::EditorComponentBase::AZ_RTTI ( EditorComponentBase  ,
"{D5346BD4-7F20-444E-B370-327ACD03D4A0}"  ,
AZ::Component   
)

Adds run-time type information to the component.

◆ BuildGameEntity()

virtual void AzToolsFramework::Components::EditorComponentBase::BuildGameEntity ( AZ::Entity *  )
inlinevirtual

Override this function to create one or more game components to represent your editor component in runtime.

Important: If your entity has a game component, you must implement this function.

This function is called by the slice builder. Any game components that you create should be attached to the game entity that is provided to this function. If you do not need to create a game component, you do not need to override this function. The provided component to the gameEntity is dynamically generated and owned by the gameEntity and should be deallocated appropriately.

Parameters
gameEntityA pointer to the game entity.

Reimplemented in AzToolsFramework::Components::EditorComponentAdapter< TController, TRuntimeComponent, TConfiguration >, AzToolsFramework::Components::GenericComponentWrapper, AzToolsFramework::Components::ScriptEditorComponent, and AzToolsFramework::Components::TransformComponent.

◆ Deactivate()

virtual void AzToolsFramework::Components::EditorComponentBase::Deactivate ( )
overridevirtual

◆ GetLocalTM()

AZ::Transform AzToolsFramework::Components::EditorComponentBase::GetLocalTM ( ) const

Gets the local transform of the entity that the component belongs to, if the entity has a transform component. An entity's local transform is the entity's position relative to its parent entity.

Returns
The local transform, if the entity has one. Otherwise, returns the identity transform, which is the equivalent of no transform.

◆ GetSerializedIdentifier()

AZStd::string AzToolsFramework::Components::EditorComponentBase::GetSerializedIdentifier ( ) const
finaloverride

Gets the serialzied identifier of this component within an entity.

Returns
The serialized identifier of this component.

◆ GetTransform()

AZ::TransformInterface * AzToolsFramework::Components::EditorComponentBase::GetTransform ( ) const

Gets the transform interface of the entity that the component belongs to, if the entity has a transform component. A transform positions, rotates, and scales an entity in 3D space.

Returns
A pointer to the transform interface. Might be null if you did not include "TransformService" in the component's AZ::ComponentDescriptor::GetRequiredServices().

◆ GetWorldTM()

AZ::Transform AzToolsFramework::Components::EditorComponentBase::GetWorldTM ( ) const

Gets the world transform of the entity that the component belongs to, if the entity has a transform component. An entity's world transform is the entity's position within the entire game space.

Returns
The world transform, if the entity has one. Otherwise, returns the identity transform, which is the equivalent of no transform.

◆ Init()

virtual void AzToolsFramework::Components::EditorComponentBase::Init ( )
overridevirtual

Initializes the component's resources. Overrides AZ::Component::Init().

Important: Components derived from EditorComponentBase must call the Init() function of the base class.

(Optional) You can override this function to initialize resources that the component needs.

Reimplemented in AzToolsFramework::Components::EditorComponentAdapter< TController, TRuntimeComponent, TConfiguration >, AzToolsFramework::Layers::EditorLayerComponent, AzToolsFramework::Components::GenericComponentWrapper, AzToolsFramework::Components::ScriptEditorComponent, and AzToolsFramework::Components::TransformComponent.

◆ IsSelected()

bool AzToolsFramework::Components::EditorComponentBase::IsSelected ( ) const

Identifies whether the component is selected in the editor.

Returns
True if the component is selected in the editor. Otherwise, false.

◆ OnAfterEntitySet()

void AzToolsFramework::Components::EditorComponentBase::OnAfterEntitySet ( )
finaloverride

Function to call after setting the entity in this component. For an editor component, this would set up the serialized identifier.

◆ Reflect()

static void AzToolsFramework::Components::EditorComponentBase::Reflect ( AZ::ReflectContext *  context)
static

Reflects component data into a variety of contexts (script, serialize, edit, and so on).

Parameters
contextA pointer to the reflection context.

◆ SetDirty()

void AzToolsFramework::Components::EditorComponentBase::SetDirty ( )

Sets a flag on the entire entity to indicate that the entity's properties were modified. Call this function whenever you alter an entity in an unexpected manner. For example, edits that you make to one entity might affect other entities, so the affected entities need to know that something changed. You do not need to call this function when editing an entity's property in the Property Editor, because that scenario automatically sets the flag. You need to call this function only when your entity's properties are modified outside the Property Editor, such as when a script loops over all lights and alters their radii.

◆ SetPrimaryAsset()

virtual void AzToolsFramework::Components::EditorComponentBase::SetPrimaryAsset ( const AZ::Data::AssetId &  )
inlinevirtual

Implement this function to support dragging and dropping an asset onto this component.

Parameters
assetIdA reference to the ID of the asset to drag and drop.

Reimplemented in AzToolsFramework::Components::ScriptEditorComponent, and AzToolsFramework::Components::GenericComponentWrapper.

◆ SetSerializedIdentifier()

void AzToolsFramework::Components::EditorComponentBase::SetSerializedIdentifier ( AZStd::string  serializedIdentifier)
finaloverride

Sets the provided string as the serialized identifier for the component.

Parameters
serializedIdentiferThe unique identifier for this component within the entity it lives in.

The documentation for this class was generated from the following file: