[UE5] 언리얼 빌드 시스템 실습
by 브이담곰📘 이득우의 언리얼 프로그래밍 Part1 - 언리얼 C++의 이해 15강 강의 과제로 작성된 글입니다.

첫번째 실습은 프로젝트 파일을 직접 생성하는 것이다.
1. 기본 프로젝트 파일 생성하기
💨 언리얼 프로젝트 파일의 구조는 다음과 같다.

빈 폴더들의 이름을 위와 같이 변경 해준 뒤, 메모장을 열어서 다음과 같이 작성해준 후 확장자를 .uproject로 바꾼다.
{ "FileVersion": 3, "EngineAssociation": "5.1", "Category": "", "Description": "", ] }
2. 언리얼 C++ 모듈 추가하기
모듈을 관리하기 위해서 아래와 같이 uproject 명세서에 모듈 이름을 지정한다.
{ "FileVersion": 3, "EngineAssociation": "5.1", "Category": "", "Description": "", "Modules": [ { "Name": "UnrealBuildSystem", "Type": "Runtime", "LoadingPhase": "Default", "AdditionalDependencies": [ "CoreUObject" ] } ] }
3. Source 폴더 생성하기
언리얼 프로젝트가 소스 코드를 관리하는 규칙에 따라 소스 코드 구조를 구성해야 한다.


{Project Name}Editor.Target.cs → 에디터 빌드 설정
// Copyright Epic Games, Inc. All Rights Reserved. using UnrealBuildTool; using System.Collections.Generic; public class UnrealBuildSystemEditorTarget : TargetRules { public UnrealBuildSystemEditorTarget (TargetInfo Target) : base(Target) { Type = TargetType.Editor; DefaultBuildSettings = BuildSettingsVersion.V2; IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1; ExtraModuleNames.Add("UnrealBuildSystem"); } }
{Project Name}Editor.Build.cs → 모듈을 빌드하기 위한 환경 설정
using UnrealBuildTool; public class UnrealBuildSystem : ModuleRules { public UnrealBuildSystem (ReadOnlyTargetRules Target) : base(Target) { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); PrivateDependencyModuleNames.AddRange(new string[] { }); // Uncomment if you are using Slate UI // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" }); // Uncomment if you are using online features // PrivateDependencyModuleNames.Add("OnlineSubsystem"); // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true } }
4. 프로젝트 열기
.uproject를 우클릭한 뒤, Generage Visual Studio Project files 를 누르면 소스코드 내 구조를 분석하고 관련된 비주얼 스튜디오 프로젝트를 Intermediate 폴더에 자동으로 생성해준다!

5. 모듈 폴더의 소스코드 파일 수정.
UnrealBuildSystem.h
#pragma once #include "CoreMinimal.h"
UnrealBuildSystem.cpp
#include "UnrealBuildSystem.h" #include "Modules/ModuleManager.h" IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, UnrealBuildSystem, "UnrealBuildSystem");
매크로를 사용해서 모듈의 뼈대를 구축할 클래스를 생성해준다.
주 게임 모듈인 IMPLEMENT_PRIMARY_GAME_MODULE 를 사용해준다.
6. 언리얼 에디터 실행
Ctrl + F5 으로 언리얼 에디터를 실행해준다.
실행을 하면 UnrealBuildSystem에 대한 정보가 안보임 → 언리얼 오브젝트가 없기 때문

7. 오브젝트 생성


이번에는 플러그인을 직접 추가해보자.
8. 플러그인 제작

Plugins 라고 해야지 언리얼에서 폴더를 타겟팅하여 정상적으로 안에있는 소스코드를 분석한다.


✔ 꼭 이렇게 수동으로 텍스트 파일을 작성하지 않아도, 에디터 메뉴를 통해 생성할 수 있다.
"LoadingPhase" 를 통해 로딩 시점을 지정할 수 있다.

그리고 위에서 만들었던 BuildSystem의 .Build 폴더의 내용을 복사한 후 class 만 CommonUtility의 이름으로 바꿔준다.🥴

6. CommonUtility.cpp 파일에 아래와 같이 작성해준다.
#include "CommonUtility.h" #include "Modules/ModuleManager.h" IMPLEMENT_MODULE(FDefaultModuleImpl, CommonUtility)
7. Build를 하고 에디터를 실행시킨 후, 새로운 클래스를 만드려 할 때, 우리가 추가한 CommonUtilty로 바꿀 수 있다.


✔ 이렇게 분류해준 파일 토대로 public에 있는 헤더만 참조할 수 있게 된다.

10.모듈이름 _API 매크로를 삭제해줌으로써 안전하게 외부모듈이 참조할 수 없도록 지정하는 것이 좋다.


12. 만들어진 모듈을 빌드 파일에 추가해주면, 해당 프로젝트에서 생성한 클래스에서 같은 폴더에 있는 것 처럼 헤더에 추가해서 사용할 수 있다.
#pragma once #include "CoreMinimal.h" #include "UObject/NoExportTypes.h" #include "Person.h" #include "MyObject.generated.h" /** * */ UCLASS() class UNREALBUILDSYSTEM_API UMyObject : public UPerson { GENERATED_BODY() };
빌드를 해보자!!!!!!!!!!!!두구두구🥁🥁🥁🥁🥁🥁🥁🥁🥁🥁🥁🥁🥁🥁🥁🥁🥁

9. 게임 빌드

2. 현재 Visual Studio의 빌드 설정을 확인해보면 아래와 같다.

프로젝트 폴더 > Source > 프로젝트파일이름.Target.cs 라는 파일을 생성해주고 아래와 같이 작성해준다.
// Copyright Epic Games, Inc. All Right Reserved. using UnrealBuildTool; using System.Collections.Generic; public class UnrealBuildSystemTarget : TargetRules { public UnrealBuildSystemTarget( TargetInfo Target) : base(Target) { Type = TargetType.Game;// Type정보에 Game이라는 Property 지정 필수! DefaultBuildSettings= BuildSettingsVersion.V2; IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1; ExtraModuleNames.Add("UnrealBuildSystem"); } }
※ 오타 조심!
3. 수정된 파일을 업데이트 하고 비주얼스튜디오를 확인해보면 빌드 타겟이 3가지 추가된 것을 볼 수 있다.

✨ Check, Insure 같은 Assertion 매크로는 Shipping 빌드에서 제외된다.
4. 빌드 확인


5. 게임 에셋 모음들을 플랫폼에 튜닝하기.


6. 빌드 파일 실행

블로그의 정보
농담곰담곰이의곰담농
브이담곰