How to register properly my custom component?

0

Hi guys! I'm fairly new in LY, and I'm trying to figure out with registering of the components. Recently I tried to create my own component for an entity. It compiles finely without any errors. But something going wrong, during LumberyardEditor starting... and I got this error

REMOVEDUPLOAD

this is my code :

header - https://pastebin.com/6vd8v8zw

cpp - https://pastebin.com/yAepvtDi

also I add MyComponent in "module" for reginster with pushing in to descriptors;

            MyProject123Module() : CryHooksModule()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.push_back(MyProject123SystemComponent::CreateDescriptor());
m_descriptors.push_back(MyComponent::CreateDescriptor());
}
feita há 5 anos205 visualizações
4 Respostas
0
Resposta aceita

I found my mistake It's raise an error with original engine's binaries and silently "doing nothing" with my compiled engine binaries - because of the line

AZ::EditContext* edit = serialize->GetEditContext();

need to be place in upper if-statment block (not out side it!). So working code now look like this -

	void MyComponent::Reflect(AZ::ReflectContext *context)
{
AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context);
if (serialize)
{
serialize->Class<MyComponent, AZ::Component >()
->Version(1)
->Field("Value", &MyComponent::m_value)
;
AZ::EditContext* edit = serialize->GetEditContext();
if (edit)
{
edit->Class<MyComponent>("My Component", "")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "MyProject123")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game"))
->DataElement(AZ::Edit::UIHandlers::Default, &MyComponent::m_value, "Value", "How much value is big.");
}
}
}
respondido há 5 anos
0

Yep, there is various UUID because I tried to generate few times new UUID, I'm just thinking maybe something wrong with it. But error raise with any UUID. Moreover, now I compile whole engine and if I register my custom component in discriptors table The LY Editor just won't starting (without any errors). And if I comment the registration of component the LYEditor starts fine. So what a cause of this behaviour ? Oo

respondido há 5 anos
0

The UUID for MyComponent in your header file is

{53C195D7-9D87-4B29-B964-16E08E728F36}

, which is not what's appearing in your error message. Are you sure you're building the right file?

respondido há 5 anos
0

I'm just using as a example code base in dir "Lumberyard\1.15.0.0\dev\MultiplayerSample\Gem\Code\Source\Components"

my component almost have the same major code parts, to showapping in editor's pop-up menu with components, and I'm just curious why it's not working for me? With original engine's binaries it was raising some error(prev. pic), but now it just silently ignore

respondido há 5 anos

Esta postagem está fechada: a adição de novas respostas, comentários e votos está desativada.