o3de / o3de

Open 3D Engine (O3DE) is an Apache 2.0-licensed multi-platform 3D engine that enables developers and content creators to build AAA games, cinema-quality 3D worlds, and high-fidelity simulations without any fees or commercial obligations.
https://o3de.org
Other
7.7k stars 2.19k forks source link

DPE, plus button with map container does not work #17287

Closed michalpelka closed 9 months ago

michalpelka commented 9 months ago

Describe the bug We observed that some of our components cannot be used with the development build. Those components internally are reflecting AZStd::map.

Assets required I've build minimal code example for you:

#pragma once

#include <AzCore/Component/Component.h>
#include <AzCore/std/containers/unordered_map.h>
class MySampleComponent : public AZ::Component
{
public:
   AZ_COMPONENT(MySampleComponent, "{E36C4B2C-794B-46E3-8E8D-05A6C705E467}");
   MySampleComponent() = default;
   ~MySampleComponent() override = default;

   static void Reflect(AZ::ReflectContext* context);
   // AZ::Component overrides ...
   void Activate() override {};
   void Deactivate() override {};

private:
    AZStd::unordered_map<AZStd::string, AZStd::string> m_map;
};
#include "MySampleComponent.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>

void MySampleComponent::Reflect(AZ::ReflectContext* context)
{
    if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
    {
        serializeContext->Class<MySampleComponent, AZ::Component>()
            ->Version(0)
            ->Field("m_map", &MySampleComponent::m_map);
        if (auto editContext = serializeContext->GetEditContext())
        {
            editContext->Class<MySampleComponent>("MySampleComponent", "MySampleComponent")
                ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
                ->Attribute(AZ::Edit::Attributes::Category, "SAMPLE")
                ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
                ->DataElement(AZ::Edit::UIHandlers::Default, &MySampleComponent::m_map, "m_map", "m_map");
        }
    }
}

Steps to reproduce Steps to reproduce the behavior:

  1. Add cited code to the project's Gem (Cmake, create a descriptor)
  2. Compile against development
  3. Add component "MySampleComponent" to any entity
  4. Click on the plus sign to populate the map with elements.
  5. Nothing happens. Expected behavior A window with a key should appear.

Actual behavior Actutally nothing is happening

Screenshots/Video image

Found in Branch Name of or link to the branch where the issue occurs.

Commit ID from o3de/o3de Repository f28481174e6a8aa8be857c82fa2e720cc3f10d1d

Desktop/Device (please complete the following information):

Additional context It is present in ROS 2 Gem spawner component. It works in 2310.1 release.

michalpelka commented 9 months ago

I've tested, it is not working on Windows as well.

alexmontAmazon commented 9 months ago

fix in review here: https://github.com/o3de/o3de/pull/17292

alexmontAmazon commented 9 months ago

fixed in development branch.