Unreal/이득우의 언리얼 프로그래밍
[UE5/Part1-1강] UGameInstance 클래스 재구현하기
이제ise이제
2023. 12. 18. 15:50
인프런 이득우의 언리얼 프로그래밍 Part1을 수강하며 작성한 강의 노트입니다.
파란색 : 강의 외 추가 조사
빨간색 : 중요 내용
언리얼 엔진이 게임을 시작하기 전에 GameInstance를 만들고 GameInstance가 가진 init함수를 호출
GameInstance.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "MyGameInstance.generated.h"
/**
*
*/
UCLASS()
class HELLOUNREAL_API UMyGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
// 언리얼 엔진이 제공하는 부모 클래스(UgameInstance)가 가진 Init()함수를 overriding 하여 재구현
virtual void Init() override;
private:
};
재구현 시 주의점
언리얼 엔진 플로우를 정상적으로 동작하기 위해, 상위 클래스의 가상함수를 꼭 실행시키기
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyGameInstance.h"
void UMyGameInstance::Init()
{
// 재구현할 때는 언리얼 엔진 플로우를 정상적으로 동작하기 위해, 상위 클래스의 가상함수를 꼭 실행시키기
Super::Init();
}