I’m following this user guide: Creating a Component
to create a C++ component for Lumberyard, but I don’t know where did I go wrong that the component won’t appear in the editor.
I did the following step:
- Add new file into the project I created:
PlayerCtrlComponent.cpp & PlayerCtrlComponent.h
-
I copy the code of a component (CameraRigComponent) for thePlayerCtrlComponent, I do this for testing purpose, I just want to see if the component actually can be assigned to an entity.
-
I edit the following things of copied CameraRigComponent, just to make the editor think the component is not duplicated:
*namespace Camera —> TestTest
*GUID, I replace the own one with the new one
*class name CameraRigComponent --> PlayerCtrlComponent
*Edit the following code
void PlayerCtrlComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("PlayerCtrlService"));
}
void PlayerCtrlComponent::Reflect(AZ::ReflectContext* reflection)
{
...
editContext->Class<PlayerCtrlComponent>("Player Ctrl", "The Player Ctrl component can be used to add and remove behaviors to drive your player entity")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "TestTest")
...
}
-
Close the Lumberyard Editor & rebuild the project that I created (I re-build only that project, using Visual Studio feature: project only > build only Empty_Project)
-
After the build is success, I re-open the Lumberyard Editor, but the component doesn’t show up when I click the button Add component for an Entity.
Am I missing something?