diff --git a/Gems/Profiler/Code/Include/Profiler/ProfilerImGuiBus.h b/Gems/Profiler/Code/Include/Profiler/ProfilerImGuiBus.h index 5bc41e2b3c..1b50cc4185 100644 --- a/Gems/Profiler/Code/Include/Profiler/ProfilerImGuiBus.h +++ b/Gems/Profiler/Code/Include/Profiler/ProfilerImGuiBus.h @@ -8,6 +8,7 @@ #pragma once #include +#include namespace Profiler { @@ -31,5 +32,6 @@ namespace Profiler static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; }; + using ProfilerImGuiInterface = AZ::Interface; using ProfilerImGuiRequestBus = AZ::EBus; } // namespace Profiler diff --git a/Gems/Profiler/Code/Source/ProfilerImGuiSystemComponent.cpp b/Gems/Profiler/Code/Source/ProfilerImGuiSystemComponent.cpp index 73fdc83cdf..c1ed66d465 100644 --- a/Gems/Profiler/Code/Source/ProfilerImGuiSystemComponent.cpp +++ b/Gems/Profiler/Code/Source/ProfilerImGuiSystemComponent.cpp @@ -55,10 +55,22 @@ namespace Profiler ProfilerImGuiSystemComponent::ProfilerImGuiSystemComponent() { +#if defined(IMGUI_ENABLED) + if (ProfilerImGuiInterface::Get() == nullptr) + { + ProfilerImGuiInterface::Register(this); + } +#endif // defined(IMGUI_ENABLED) } ProfilerImGuiSystemComponent::~ProfilerImGuiSystemComponent() { +#if defined(IMGUI_ENABLED) + if (ProfilerImGuiInterface::Get() == this) + { + ProfilerImGuiInterface::Unregister(this); + } +#endif // defined(IMGUI_ENABLED) } void ProfilerImGuiSystemComponent::Activate()