UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TypedElementObjectInterface.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Templates/Casts.h"
8#include "UObject/Interface.h"
9#include "UObject/Object.h"
12
13#include "TypedElementObjectInterface.generated.h"
14
15class UClass;
16struct FFrame;
17
18UINTERFACE(MinimalAPI, BlueprintType, meta = (CannotImplementInterfaceInBlueprint))
23
25{
27
28public:
33
38
44 template <class CastTo>
49
56 template <class CastTo = UObject>
58 {
59 if (!TargetClass)
60 {
61 return nullptr;
62 }
63
64 UObject* ObjectPtr = GetObject(InElementHandle);
65 if (ObjectPtr && ObjectPtr->IsA(TargetClass))
66 {
67 return (CastTo*)ObjectPtr;
68 }
69
70 return nullptr;
71 }
72
73
81 UFUNCTION(BlueprintCallable, Category="TypedElementInterfaces|Object")
83
87 UFUNCTION(BlueprintCallable, Category = "TypedElementInterfaces|Object")
89};
90
91template <>
93{
94 UObject* GetObject() const { return InterfacePtr->GetObject(*this); }
95 UClass* GetObjectClass() const { return InterfacePtr->GetObjectClass(*this); }
96
97 template <class CastTo>
98 CastTo* GetObjectAs() const { return InterfacePtr->GetObjectAs<CastTo>(*this); }
99
100 template <class CastTo>
101 CastTo* GetObjectAs(TSubclassOf<CastTo> TargetClass) const { return InterfacePtr->GetObjectAs<CastTo>(*this, TargetClass); }
102};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UINTERFACE(...)
Definition ObjectMacros.h:780
Definition TypedElementObjectInterface.h:25
CastTo * GetObjectAs(const FTypedElementHandle &InElementHandle, TSubclassOf< CastTo > TargetClass)
Definition TypedElementObjectInterface.h:57
virtual TYPEDELEMENTRUNTIME_API UObject * GetObject(const FTypedElementHandle &InElementHandle)
Definition TypedElementObjectInterface.cpp:11
CastTo * GetObjectAs(const FTypedElementHandle &InElementHandle)
Definition TypedElementObjectInterface.h:45
virtual TYPEDELEMENTRUNTIME_API UClass * GetObjectClass(const FTypedElementHandle &InElementHandle)
Definition TypedElementObjectInterface.cpp:16
Definition SubclassOf.h:30
Definition Class.h:3793
Definition Interface.h:19
bool IsA(OtherClassType SomeBase) const
Definition UObjectBaseUtility.h:619
Definition Object.h:95
Definition TypedElementObjectInterface.h:20
Definition Stack.h:114
Definition TypedElementHandle.h:625
Definition TypedElementHandle.h:18
Definition TypedElementHandle.h:271
CastTo * GetObjectAs() const
Definition TypedElementObjectInterface.h:98
UObject * GetObject() const
Definition TypedElementObjectInterface.h:94
CastTo * GetObjectAs(TSubclassOf< CastTo > TargetClass) const
Definition TypedElementObjectInterface.h:101
UClass * GetObjectClass() const
Definition TypedElementObjectInterface.h:95
Definition TypedElementHandle.h:396