Notice
Recent Posts
Recent Comments
Link
스토리지
Forward Declaration (전방 선언) 본문
해당 문제는 언리얼이 아니라 C++ 문제이다.
1. 결과
// Bird.h
#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "Bird.generated.h"
// Header로 추가하지 않고 선언만 함.
class UCapsuleComponent;
class USkeletalMeshComponent;
class USpringArmComponent;
class UCameraComponent;
UPROPERTY(VisibleAnywhere)
UCapsuleComponent *Capsule;
UPROPERTY(VisibleAnywhere)
USkeletalMeshComponent *BirdMesh;
UPROPERTY(VisibleAnywhere)
USpringArmComponent *CameraBoom;
UPROPERTY(VisibleAnywhere)
UCameraComponent *ViewCamera;
// Bird.cpp
#include "Pawns/Bird.h"
#include "Components/CapsuleComponent.h"
#include "Components/SkeletalMeshComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
- Header에서 필요한 헤더파일을 추가하지 않는다.
- return type으로 사용할 때나 포인터 변수만 사용이 가능하다.
- 대신 class 해당객체자료형; 으로 선언만 한다. 해당 객체는 cpp파일에서 불러온다.
- cpp파일에서 불러오지 않고 사용 후 빌드 시 컴파일 에러가 발생한다.
2. 이 방식을 사용하는 이유
#include 된 것이 변경되면 이를 include하는 모든것이 재컴파일 되므로 성능적 저하를 불러올 수 있다.
또한 Header들이 순환이 발생될 수 있기 때문에 cpp에서 헤더를 불러오도록 한다.
'Unreal Engine > 0. Unreal 5' 카테고리의 다른 글
카메라 추가 (0) | 2023.07.12 |
---|---|
Pawn 움직이기 (0) | 2023.07.12 |
Pawn 추가 (0) | 2023.07.12 |
Component (0) | 2023.07.11 |
UPROPERTY / UFUNCTION (0) | 2023.07.11 |
Comments