Unreal Engine and C++ (1)
개요
Class 마법사(Unreal Engine에서 새로운 Class 만들기)
File > New C++ Class >


MyActor.h
1 | // Fill out your copyright notice in the Description page of Project Settings. |
BeingPalay()는 액터가 플레이 가능한 상태로 게임에 들어왔음을 알려주는 이벤트Tick()는 지난번 들여온 이후의 경과된 시간만큼 프레임당 한 번씩 호출된다
MyActor.Cpp
1 | // Fill out your copyright notice in the Description page of Project Settings. |
PrimaryActorTick.bCanEverTick = true를 제거함으로써 필요치 않은 반복 로직을 제거할 수 있다
컴파일

Class
접두사
A: 스폰가능한 게임플레이 오브젝트의 베이스 클래스에서 확장(Actor, 월드에서 바로 스폰 가능)U: 모든 게임플레이 오브젝트의 베이스 클래스에서 확장(월드에서 바로 인스턴싱 불가, 엑터에 속해야함, 컴포넌트와 같은 오브젝트)
선언
1 | UCLASS([specifier, specifier, ...], [meta(key = value, key = value, ...)]) |
UCLASS매크로에 클래스 지정자나 메타데이터와 같은 지시어가 전달됨GENERATED_BODY()매크로는 본문 제일 처음에 와야함- 아래의
Class Specifier를 위의specifier란에 용도에 맞게 적어서 쓸 수 있다
Class Specifier
프로퍼티가 에디터에 보이도록 만들기
MyActor.h
1 | // Fill out your copyright notice in the Description page of Project Settings. |
GENERATED_BODY()와UPROPERTY()뒤에는;을 붙이지 않는다- 아래의
프로퍼티 지정자를UPROPERTY()에 적절히 사용함으로써 위의 상황에선 다음과 같은 설정을 할 수 있다

MyActor.h
1 | // Fill out your copyright notice in the Description page of Project Settings. |

MyActor.cpp
1 | // Fill out your copyright notice in the Description page of Project Settings. |

종속적인 프로퍼티 계산 시키기
1 | void AMyActor::PostInitProperties() |
위와 같이 선언해주면 초기값만 계산한다
MyActor.h
1 | // Fill out your copyright notice in the Description page of Project Settings. |
MyActor.cpp
1 | // Fill out your copyright notice in the Description page of Project Settings. |

여러가지 프로퍼티 지정자
프로퍼티 지정자