본문으로 건너뛰기
Unreal Engine C++ 기초집LESSON 05

Unreal Reflection System

난이도입문
예상 시간35분
선수지식4강의 첫 C++ Actor

5강. Unreal Reflection System

1. 이번 강의에서 해결할 문제

C++ 변수는 컴파일되지만 Details 패널에 보이지 않고 Blueprint에서 함수도 호출할 수 없습니다. Unreal이 C++ 타입 정보를 알아야 제공할 수 있는 기능과 매크로 옵션의 범위를 구분합니다.

2. 학습 목표

3. 핵심 개념

Unreal Header Tool은 UCLASS, USTRUCT, UENUM, UPROPERTY, UFUNCTION으로 표시된 선언을 분석해 에디터 노출, 직렬화, Blueprint 호출과 GC 추적에 필요한 코드를 생성합니다. 모든 C++ 멤버가 자동으로 Reflection 대상이 되는 것은 아닙니다.

편집 범위와 읽기 범위는 별개입니다. EditDefaultsOnly는 Blueprint 클래스 기본값에서 수정하게 하고, VisibleAnywhere는 구성 요소 자체 교체는 막되 내부 속성을 보게 합니다. BlueprintReadOnly는 Blueprint 그래프가 값을 읽을 수 있지만 직접 덮어쓰지는 못하게 합니다.

4. 단계별 실습

파일 경로: Source/TopDownSurvival/Actors/SurvivalTarget.h

SurvivalTarget.h · 핵심 부분
UCLASS(Blueprintable)
class TOPDOWNSURVIVAL_API ASurvivalTarget : public AActor
{
GENERATED_BODY()

public:
ASurvivalTarget();

UFUNCTION(BlueprintCallable, Category = "Target")
void SetTargetActive(bool bNewActive);

protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Target",
meta = (ClampMin = "0.0", Units = "deg/s"))
float RotationSpeed = 45.0f;

UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category = "Target")
bool bIsActive = true;

UFUNCTION(BlueprintImplementableEvent, Category = "Target")
void OnTargetActiveChanged(bool bNewActive);
};

파일 경로: Source/TopDownSurvival/Actors/SurvivalTarget.cpp

SurvivalTarget.cpp · 추가
void ASurvivalTarget::SetTargetActive(bool bNewActive)
{
if (bIsActive == bNewActive)
{
return;
}

bIsActive = bNewActive;
SetActorTickEnabled(bIsActive);
OnTargetActiveChanged(bIsActive);
}

Blueprint Editor

BP_SurvivalTarget에서 Event On Target Active Changed를 구현하고 활성 상태에 따라 Print String 색상을 바꿉니다. 규칙은 C++가 결정하고 시각 반응은 Blueprint가 담당합니다.

5. 코드가 동작하는 이유

BlueprintCallable은 C++ 구현을 Blueprint 노드로 호출하게 합니다. BlueprintImplementableEvent는 C++가 이벤트 발생 시점만 정하고 Blueprint가 표현을 구현하게 합니다. 상태가 같으면 즉시 반환해 불필요한 이벤트 중복을 막습니다.

6. 자주 하는 실수와 해결법

7. 직접 실습

8. 이해 점검 질문 3개

9. 핵심 요약

MINI QUIZ

Unreal Reflection System 미니 퀴즈

선택 즉시 정답과 해설을 확인할 수 있습니다. 결과는 이 브라우저에만 저장됩니다.

0 / 2
  1. 문제 1“Unreal Reflection System” 실습 결과를 확인할 때 적용해야 할 설명은 무엇인가요?
  2. 문제 2‘매크로 줄 끝에 세미콜론 추가’ 상태에 관한 “Unreal Reflection System” 본문의 설명으로 가장 알맞은 것은 무엇인가요?
LESSON STATUS

학습을 마쳤나요?

직접 실습과 점검 질문까지 확인한 뒤 완료로 표시하세요.

5강. Unreal Reflection System 미완료 상태