2
1

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】UEnumで範囲ベースforを行うメモ

Posted at

確認したバージョンはUE4.27.2です。

ググれば出てくるのだが、よく忘れるので自分用メモ。

宣言側 (.h)

#include "Misc/EnumRange.h"

UENUM()
enum class EElementType : uint8
{
	Earth,
	Fire,
	Wind,
	Water,
	Count	UMETA(Hidden)
};

ENUM_RANGE_BY_COUNT(EElementType, EElementType::Count);
  • ENUM_RANGE_BY_COUNT()マクロの他に ENUM_RANGE_BY_FIRST_AND_LAST()などがある。
    • EnumRange.h
    • 内部的には static const な変数を宣言するだけ。なので変な負荷はないだろう。

定義側 (.cpp)

for (EElementType ElementType : TEnumRange<EElementType>())
{
	SettingArray.Add(LoadInitialSettings(ElementType));
}

参考URL

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?