5
3

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 5 years have passed since last update.

Unreal Engine 4メモ:エディット中なのかゲーム中なのか知りたい

Last updated at Posted at 2018-02-19

現在のEWorldType::Typeを確認するとエンジンが実行中のワールドの状態を取得できます。

私はUMGのアニメーションのカスタムイベントを拾ってC++から操作する実装をしました。ウィジェットのアニメーションをエディタ上でアニメーションプレビュー実行するとワールドに存在しないインスタンスが参照される問題があったのでこちらで分岐しました。

UWorldの中に現在の状態が入っている

World.h
EWorldType::Type UWorld::WorldType;
sample.cpp
if (GetWorld()->WorldType == EWorldType::Editor || GetWorld()->WorldType == EWorldType::EditorPreview)
{
	// エディット中はゲームのインスタンスが無いのでカスタムイベントの内容を実行しない
	return;
}

EWorldType::Type

名前 説明
None An untyped world, in most cases this will be the vestigial worlds of streamed in sub-levels. ほとんどの場合サブレベルからロードされたときにこの状態。未確認。
Game The game world. 実際にゲームを実行中の時。未確認。
Editor A world being edited in the editor. エディタを実行中。未確認。
PIE A Play In Editor world. エディタ内でPlayをしている時。
EditorPreview A preview world for an editor tool. UMGのアニメーションを編集し、アニメーションのプレビューを行ったときにこのモードになることを確認。
GamePreview A preview world for a game. ゲームのプレビュー中。PIEとの違いが分からない。未確認。
Inactive An editor world that was loaded but not currently being edited in the level editor. ロード済みであるが、レベルエディタで現在編集されていないエディタワールド。未確認。

そのうち未確認のところも埋めたいです。

UEngine::IsEditor

上記もあったのですが、これは用途が違うようです。

参照

フォーラムにあった質問「How can I tell if I'm in standalone or new editor window」
WorldType
EWorldType::Type

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?