// Distributed under the MIT License (MIT) (see accompanying LICENSE file) #include "ImGuiPrivatePCH.h" #include "ImGuiInputHandlerFactory.h" #include "ImGuiInputHandler.h" UImGuiInputHandler* FImGuiInputHandlerFactory::NewHandler(const FStringClassReference& HandlerClassReference, FImGuiModuleManager* ModuleManager, UGameViewportClient* GameViewport, int32 ContextIndex) { UClass* HandlerClass = nullptr; if (HandlerClassReference.IsValid()) { HandlerClass = HandlerClassReference.TryLoadClass(); if (!HandlerClass) { UE_LOG(LogImGuiInputHandler, Error, TEXT("Couldn't load ImGui Input Handler class '%s'."), *HandlerClassReference.ToString()); } } if (!HandlerClass) { HandlerClass = UImGuiInputHandler::StaticClass(); } UImGuiInputHandler* Handler = NewObject(GameViewport, HandlerClass); if (Handler) { Handler->Initialize(ModuleManager, GameViewport, ContextIndex); Handler->AddToRoot(); } else { UE_LOG(LogImGuiInputHandler, Error, TEXT("Failed attempt to create Input Handler: HandlerClass = %s."), *GetNameSafe(HandlerClass)); } return Handler; } void FImGuiInputHandlerFactory::ReleaseHandler(UImGuiInputHandler* Handler) { if (Handler) { Handler->RemoveFromRoot(); } }