0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

UE4, 5 プロジェクトにモジュール開始,終了ファンクションを追加する

Last updated at Posted at 2023-01-05

手順

追加したモジュールには自動的にクラスとメソッドが追加されるが、プロジェクトのプライマリモジュールには追加されないので手動で追加する

1. <プロジェクト名>.hにFDefaultGameModuleImpl継承クラスを宣言し、void StartupModule()void ShutdownModule()をオーバーライドする。

MyProject.h
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"

class FMyProjectModule: public FDefaultGameModuleImpl
{
public:
	virtual void StartupModule() override;
	virtual void ShutdownModule() override;
};

#include "Modules/ModuleManager.h"

2. <プロジェクト名>.cppに実装しIMPLEMENT_PRIMARY_GAME_MODULEの最初の引数を1で作ったクラス名に書き換える。

MyProject.cpp
#include "MyProject.h"

void MyProject::StartupModule()
{
	UE_LOG(LogTemp, Warning, TEXT("Module Started"));
}

void MyProject::ShutdownModule()
{
	UE_LOG(LogTemp, Warning, TEXT("Module Shutdown"));
}

IMPLEMENT_PRIMARY_GAME_MODULE(FMyProjectModule, MyProject, "MyProject");

IMPLEMENT_PRIMARY_GAME_MODULE(FMyProjectModule モジュールクラス名に変更, MyProject (変更なし), "MyProject"(変更なし))

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?