mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-19 08:50:31 +00:00
42 lines
1012 B
C
42 lines
1012 B
C
|
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include <Core.h>
|
||
|
#include <Engine.h>
|
||
|
|
||
|
|
||
|
// Utilities helping to get a World Context.
|
||
|
|
||
|
namespace Utilities
|
||
|
{
|
||
|
template<typename T>
|
||
|
FORCEINLINE const FWorldContext* GetWorldContext(const TWeakObjectPtr<T>& Obj)
|
||
|
{
|
||
|
return Obj.IsValid() ? GetWorldContext(*Obj.Get()) : nullptr;
|
||
|
}
|
||
|
|
||
|
template<typename T>
|
||
|
FORCEINLINE const FWorldContext* GetWorldContext(const T* Obj)
|
||
|
{
|
||
|
return Obj ? GetWorldContext(*Obj) : nullptr;
|
||
|
}
|
||
|
|
||
|
FORCEINLINE const FWorldContext* GetWorldContext(const UGameInstance& GameInstance)
|
||
|
{
|
||
|
return GameInstance.GetWorldContext();
|
||
|
}
|
||
|
|
||
|
FORCEINLINE const FWorldContext* GetWorldContext(const UGameViewportClient& GameViewportClient)
|
||
|
{
|
||
|
return GetWorldContext(GameViewportClient.GetGameInstance());
|
||
|
}
|
||
|
|
||
|
FORCEINLINE const FWorldContext* GetWorldContext(const UWorld& World)
|
||
|
{
|
||
|
return GetWorldContext(World.GetGameInstance());
|
||
|
}
|
||
|
|
||
|
const FWorldContext* GetWorldContextFromNetMode(ENetMode NetMode);
|
||
|
}
|