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());
}
질문됨 5년 전205회 조회
4개 답변
0
수락된 답변

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.");
}
}
}
답변함 5년 전
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

답변함 5년 전
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?

답변함 5년 전
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

답변함 5년 전

이 게시물은 마감됨: 새 답변, 댓글 및 투표 추가가 비활성화되었습니다.

관련 콘텐츠