Why Won’t My Components Show in the Damn Editor!!!!

First of all, calm down. Take a deep breath. I know it’s frustrating, probably more frustrating than trying to play slither.io while compiling.

First watch some screaming goats for awhile.

Once you’ve watched the goats, hopefully you’ve made it back to this article.

Sometimes when you make a custom component in C++, it won’t show up in the editor. When I do this, it’s usually my own fault. But to my defense, there are a lot of things you could do wrong to cause this.

The Checklist

Here are some things I’ve come across to check for. (Yes, ending a sentence in a preposition is proper English)

1. Did you give your component an unique GUID

Everyone knows programming is all about copy paste development. It certainly feels that way with Lumberyard sometimes, since the best documentation on it is reading the source.

However, sometimes when you copy and paste, you forget to change the GUID for your component you just pasted. Shame on you.

Make sure you created a unique guid for your component!

2. Did you register the component

Remember you need to register the component in the *Module.cpp file. For my input tutorial series, this would be the TutorialSeriesModule.cpp

namespace TutorialSeries
{
    class TutorialSeriesModule
        : public CryHooksModule
    {
    public:
        AZ_RTTI(TutorialSeriesModule, "{33A3448B-6DF2-421F-A106-26FEADC7CBE2}", CryHooksModule);
        AZ_CLASS_ALLOCATOR(TutorialSeriesModule, AZ::SystemAllocator, 0);

        TutorialSeriesModule()
            : CryHooksModule()
        {
            m_descriptors.insert(m_descriptors.end(), {
                TutorialSeriesSystemComponent::CreateDescriptor(),
                TutorialSeriesCharacterComponent::CreateDescriptor(),
                TutorialSeriesCameraComponent::CreateDescriptor()
            });
        }

        /**
         * Add required SystemComponents to the SystemEntity.
         */
        AZ::ComponentTypeList GetRequiredSystemComponents() const override
        {
            return AZ::ComponentTypeList{
                azrtti_typeid<TutorialSeriesSystemComponent>(),
            };
        }
    };
}

// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
// The first parameter should be GemName_GemIdLower
// The second should be the fully qualified name of the class above
AZ_DECLARE_MODULE_CLASS(TutorialSeries_7a17c44ce76744e1b646e6d8556372c8, TutorialSeries::TutorialSeriesModule)

See lines 15 and 16.

3. Did you put the curly braces around the GUID?

They look like the center of this image.

Ok, for realzies, it should look like this:

class TutorialSeriesCharacterComponent
    : public AZ::Component,
        public AzFramework::InputChannelEventListener,
        public AZ::TickBus::Handler,
        public AZ::TransformNotificationBus::Handler
{
public:
    AZ_COMPONENT(TutorialSeriesCharacterComponent, "{F52E6197-C72B-4BEF-99CB-FE41C36CF882}");

    ~TutorialSeriesCharacterComponent() override = default;

    static void Reflect(AZ::ReflectContext* reflection);

See line 8 above.

4. Did you add it to the Add Component menu?

Your custom component will not show up under the Add Component menu in the editor unless you tell it to. You do this by adding another link in the reflection chain.

void TutorialSeriesCharacterComponent::Reflect(AZ::ReflectContext *reflection)
{
    if (auto serializationContext = azrtti_cast(reflection))
    {
        serializationContext->Class()
            ->Version(1)
            ->Field("Movement scale", &TutorialSeriesCharacterComponent::MovementScale)
            ->Field("Rotation Speed", &TutorialSeriesCharacterComponent::RotationSpeed)
            ->Field("Slice To Spawn", &TutorialSeriesCharacterComponent::SliceToSpawn);

        if (auto editContext = serializationContext->GetEditContext())
        {
            editContext->Class("TutorialSeriesCharacterComponent", "Main controller component")
                ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
                ->Attribute(AZ::Edit::Attributes::Category, "TutorialSeries")
                ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game"))
                ->DataElement(nullptr, &TutorialSeriesCharacterComponent::MovementScale, "Movement scale", "How fast the character moves")
                ->DataElement(nullptr, &TutorialSeriesCharacterComponent::RotationSpeed, "Rotation Speed", "The speed multiplier to apply to mouse rotation")
                ->DataElement(nullptr, &TutorialSeriesCharacterComponent::SliceToSpawn, "Slice To Spawn", "This is the slice that will be spawned when clicking");
        }
    }
}

See line 16

5. Are you running the correct editor?

The editor gets compiled like everything else in Lumberyard. Ensure you are running the editor from the same place you are compiling your game.

So if you are running lmbr_waf.bat build_win_x64_vs2015_debug for instance, then be sure to run the editor from the dev\Bin64vc140.Debug folder.

6. Did you add the component to your waf_file?

Leonard from the community slack reminded me that sometimes we forget to add files to the *.waf_file file. So make sure you added your component there with the correct path and all that.

Know of Other Common Issues?

What about you? Have you ran into problems that prevented a component from showing up in the editor?

Let me know. Leave a comment. Send an email (lumberyard.tutorials@gmail.com). Or join the community slack

2 thoughts on “Why Won’t My Components Show in the Damn Editor!!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s