initial commit; cv 0.0.3
This commit is contained in:
46
Reflection/UnrealObjectRef.hpp
Normal file
46
Reflection/UnrealObjectRef.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <type_traits>
|
||||
|
||||
#include <DynamicOutput/DynamicOutput.hpp>
|
||||
|
||||
#include <Unreal/UObjectGlobals.hpp>
|
||||
#include <Unreal/UObject.hpp>
|
||||
#include <Unreal/UClass.hpp>
|
||||
#include <Unreal/CoreUObject/UObject/Class.hpp>
|
||||
#include <Unreal/CoreUObject/UObject/UnrealType.hpp>
|
||||
#include <Static/ClassCache.hpp>
|
||||
|
||||
namespace PalUIExtension::Reflection
|
||||
{
|
||||
using namespace RC;
|
||||
using namespace RC::Unreal;
|
||||
|
||||
class UnrealObjectRef
|
||||
{
|
||||
public:
|
||||
explicit UnrealObjectRef(const TCHAR* Path, const TCHAR* DebugTag)
|
||||
: m_path(Path), m_debug_tag(DebugTag) {
|
||||
Static::ClassCache::RegisterSlot(&m_cached);
|
||||
}
|
||||
|
||||
auto Get() -> UObject*
|
||||
{
|
||||
if (m_cached) return m_cached;
|
||||
|
||||
m_cached = UObjectGlobals::StaticFindObject<UObject*>(nullptr, nullptr, m_path, false);
|
||||
if (!m_cached)
|
||||
{
|
||||
Output::send<LogLevel::Warning>(STR("[{}] could not resolve '{}'\n"), m_debug_tag, m_path);
|
||||
}
|
||||
return m_cached;
|
||||
}
|
||||
|
||||
private:
|
||||
const TCHAR* m_path;
|
||||
const TCHAR* m_debug_tag;
|
||||
UObject* m_cached{};
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user