ftftgop3 2024. 5. 4. 16:23

언리얼 소스 코드 구조

언리얼 오브젝트에 관련 된 헤드은 Classes 폴더에 저장

외부에 공개하는 H파일은 Public 폴더로 CPP 파일은 Private 폴더에 분류

 

현재 프로젝트도 언리얼 코드 구조로 변경

Source/ArenaBattle 이동 후 Public, Private 폴더 생성 후

H파일은 Public 폴더이동, CPP 파일은 Private 폴더로 이동

언리얼 프로젝트 재 빌드 후 에디터 변경

 

모듈의 역할

언리얼 엔진은 주 게임 모듈을 사용 해 게임 프로젝트 로직 관리

주 게임 모듈 말고 별도의 게임 모듈을 생성 해 두개의 모듈로 게임 프로젝트 구성

에디터에서는 C++ 프로젝트 생성 시 주 게임 모듈을 자동 생성

 

추가 모듈 생성 시 필요한 요소

위에 구조 처럼 Public( H 파일), Private(Cpp), 모듈 및 모듈명으로 된 Build.cs 파일 필요

1. ArenaBattleSetting 폴더 안에 Public, Privet ArenaBattleSetting.Build.cs 배치 후

2. ArenaBattleSetting.h, ArenaBattleSetting.cpp 추가

3. Cpp 파일에 모듈 추가 코드 작성

 

프로젝트 재빌드 후 ArenaBattleSetting 모듈 인식

 

비주얼 스튜디오에서 추가 모듈 빌드 하게 셋팅

ArenaBattleTarget, ArenaBattleEditorTarget에 추가 모듈 이름 추가

Binaries 폴더에 Dll 파일 생성 완료

// Fill out your copyright notice in the Description page of Project Settings.

using UnrealBuildTool;
using System.Collections.Generic;

public class ArenaBattleTarget : TargetRules
{
	public ArenaBattleTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Game;

		ExtraModuleNames.AddRange( new string[] { "ArenaBattle",
        "ArenaBattleSetting"} );
    }
}
using UnrealBuildTool;
using System.Collections.Generic;

public class ArenaBattleEditorTarget : TargetRules
{
	public ArenaBattleEditorTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Editor;

		ExtraModuleNames.AddRange( new string[] { "ArenaBattle", "ArenaBattleSetting" } );
	}
}

 

언리얼 에디터가 Dll 파일 로딩 

ArenaBattle.uproject 파일에 새로운 모듈에 대한 정보 추가

 

ArenaBattleSetting 파일이 가장 먼저 로딩 LoadingPhase : preDefault 설정

ArenaBattle 모듈이  Setting 종속 하게 동작 하게 수정

{
	"FileVersion": 3,
	"EngineAssociation": "4.19",
	"Category": "",
	"Description": "",
	"Modules": [
		{
			"Name": "ArenaBattleSetting",
			"Type": "Runtime",
			"LoadingPhase": "PreDefault"
		},
		{
			"Name": "ArenaBattle",
			"Type": "Runtime",
			"LoadingPhase": "Default",
			"AdditionalDependencies": [
				"Engine",
				"UMG",
				"AIModule",
				"ArenaBattleSetting"
			]
		}

	]
}

 

ArenaBattleSetting 모듈에 언리얼 오브젝트 추가

새로운 C++ 클래스에서 타켓 모듈을 ArenaBattleSetting 지정 후 생성

생성 시 4.19 버전에서는 재 생성 오류가 발생 하기 떄문에 에디터 종료 후 프로젝트 재빌드

정상적으로 재빌드 시 모듈에 오브젝트 생성