From fa4e91b05c93809da6a84d73ac34b9112f8a17d4 Mon Sep 17 00:00:00 2001 From: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> Date: Mon, 18 Oct 2021 10:51:15 -0700 Subject: [PATCH] [atom_cpu_profiler_gem_promotion] added optional AZ::Interface usage to ProfilerImGuiRequests Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> --- .../Code/Include/Profiler/ProfilerImGuiBus.h | 2 ++ .../Code/Source/ProfilerImGuiSystemComponent.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) 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()