Code to add a GEM component to Editor menu?

0

Apologies for the somewhat basic question but I am having an issue adding my GEM to the editor. I have an editContext in my reflect function as described here: http://docs.aws.amazon.com/lumberyard/latest/developerguide/component-entity-system-reflect-component.html.

However I do not see anything in the editor. Also, looking at some of the included GEMs such as Boid and lightning, it is unclear to me where they are adding menu items in the rollup bar (looking to follow the example).

Is there a simple step by step guide on how to add GEMs to editor? Current;y I'm only building using a game profile. Is it necessary to rebuild the editor code as well to see the change? Thanks!

asked 7 years ago183 views
7 Answers
0
Accepted Answer

If you have a function that overrides the "Reflect(AZ::ReflectContext* reflection)" function, that spcifies that as an editor context attribute "->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game"))" you should be able to get it as a componet into the editor.

Can you make sure, that the component how it is, works? Like, not as a gem, but straight as an editor component?

If you can verify this, I would look at how a gem and its hook into the engine works. I suspect that to be the problem. If you create a new gem, and add it to the current project (both over the project configurator), you should have everything you need already.

Check the CameraComponent.h and CameraComponent.cpp. This is a gem for an opt-in camera component, provided by Amazon.

answered 7 years ago
profile picture
EXPERT
reviewed 3 days ago
0

Thanks for the response. The default GEM looks to be a System Component type. I can see it listed under the system components in the advanced settings menu within the Project Configurator apps. But what I really want is the ability to select and manipule my GEM in the Lumberyard editor. Do I need to specify it as an Editor Component as opposed to a System Component?

answered 7 years ago
0

Thanks for that link @REDACTEDUSER

answered 7 years ago
0

I still am not sure how to add a custom component to a Gem, If I followed the link above I don't have the <projectname>game.cpp in my solution. That file is created when I create a new project from the Project Configurator but my end goal is to create a gem that creates a dynamic slice that contains my custom component.

answered 6 years ago
0

There should be a Project folder which is separate from the Gems folder which contains all Gems including the ones you create. In the Project Selector you just need to choose any Project and click the "Enable Gems" button under the Project Name. From that window you can click the "Create a new Gem" button which will create a Gem in the Gems folder which can be enabled by any Project. Just remember to check the Enabled box and then click Save in the top right of the Gems window. Only one project can be active at a time and you will need your custom Gem enabled for that project to compile and see it in the Editor. After that you just need to run "lmbr_waf configure" in the root Lumberyard directory before building. If it wasn't obvious System Components are singletons automatically added by Lumberyard that always exist in the background and are typically only used for initialization purposes or some sort of global functionality. Custom Components or Game Components are usually in the Editor menu and are what you attach to a Component Entity.

In order to get your Gem added into the Editor you should only need to do the following:

  1. Update the WAF Files - You should have at least one .waf_files file in your Gem directory enumerating all the .h/.cpp files in your Gem folder.
  2. Update the Gem wscript File - This might not be needed but any additional library includes or Gem dependencies will need added to this. This is the wscript file in your specific Gem folder, not the root Lumberyard directory or elsewhere.
  3. Update the Module Constructor Function - This is usually in GemNameModule.cpp and you will need every Component created by the Gem that isn't a base class enumerated in this. See "Module File Changes" below for details.
  4. Update every Component::Reflect Function - This is where you configure the Component for the Editor and set whether it is a System or Game Component and where it appears in the menu if it needs to be there. See "Possible Reflect Function Attributes" below for details. Module File Changes(GemNameModule.cpp)
    Module::Module() : CryHooksModule()
{
//Appends the Descriptors for Module Components
m_descriptors.insert( m_descriptors.end(), {
SystemComponentA::CreateDescriptor(),
SystemComponentB::CreateDescriptor(),
GameComponentA::CreateDescriptor(),
GameComponentB::CreateDescriptor(),
GameComponentC::CreateDescriptor(),
});
}
AZ::ComponentTypeList Module::GetRequiredSystemComponents() const
{
return AZ::ComponentTypeList
{
azrtti_typeid<SystemComponentA>(),
azrtti_typeid<SystemComponentB>(),
};
}

Possible Reflect Function Attributes(Component.cpp)


System Component Reflect Attributes:
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
Game Component Reflect Attributes:
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game"))
->Attribute(AZ::Edit::Attributes::Category, "Game")
or
->Attribute(AZ::Edit::Attributes::Category, "GemName/SubMenu/")
answered 6 years ago
0

I can not resolve LeftHand as a class in my module file

#include "Include\Hands\LeftHand.h"

but LeftHand is still unidentified

LeftHand::CreateDescriptor(),

azrtti_typeid<LeftHand>(),

Update I missed a namespace change everything compiles fine now although I don't see the component yet.

answered 6 years ago
0
answered 7 years ago

This post is closed: Adding new answers, comments, and votes is disabled.