1. 헤더파일 선언

2. 인터페이스 선언
#pragma once
#include "CoreMinimal.h"
#include "UObject/Interface.h"
#include "EventInterface.generated.h"
UINTERFACE(MinimalAPI)
class UEventInterface : public UInterface
{
GENERATED_BODY()
};
class CCTVPROJECT_API IEventInterface
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintNativeEvent)
void StartEvent();
UFUNCTION(BlueprintNativeEvent)
void EndEvent();
};
BlueprintNativeEvent는 C++에서 기본 구현을 하고 블루프린트에서도 오버라이드가 가능한 속성이다.
3. 인터페이스 호출
실제 함수 구현부
//.h
UCLASS()
class CCTVPROJECT_API ASpecialEvent : public AActor, public IEventInterface
{
GENERATED_BODY()
public:
ASpecialEvent();
protected:
virtual void BeginPlay() override;
public:
virtual void StartEvent_Implementation() override;
virtual void EndEvent_Implementation() override;
}
다른 클래스에서 호출할 때
//.cpp
for (ANormalEvent* NormalEvent : NormalEvents)
{
IEventInterface::Execute_StartEvent(NormalEvent);
}'언리얼 엔진 > 트러블슈팅' 카테고리의 다른 글
| [언리얼엔진] 마우스 커서 변경 (0) | 2025.04.27 |
|---|---|
| [언리얼엔진] Git LFS 사용법 (0) | 2025.04.26 |
| [언리얼엔진] 레벨 시퀀스 재생 C++ (0) | 2025.04.25 |
| [언리얼엔진] WidgetBlueprint 버튼 바인딩 (0) | 2025.04.24 |
| [언리얼엔진] Material Parameter 수정 (0) | 2025.04.08 |