LoginSignup
0
0

【UE5】ApplicationScaleを変更して全体のWidgetのサイズを変更

Posted at

Unreal Engineでウィジェットの表示サイズを変えるDPIスケールがありますが、
選択式で変更したかったのでApplicationScaleをいじる方法を試します。

ApplicationScale

ProjectSettingにApplicationScaleという項目を変更すると全体のWidgetの大きさが変わるようです。
image.png

変更する関数

以下の関数を作成します。

UTestObject.h
class PROJECTNAME_API UTestObject : public UObject
{
	GENERATED_BODY()

	UFUNCTION(BlueprintCallable, Category = "Test")
	static void SetApplicationScale(float NewValue);
};
UTestObject.cpp
#include "Engine/UserInterfaceSettings.h"

void UTestObject::SetApplicationScale(float NewValue) {
	UUserInterfaceSettings* UISettings = GetMutableDefault<UUserInterfaceSettings>(UUserInterfaceSettings::StaticClass());
	if (UISettings) {
		UISettings->ApplicationScale = NewValue;
	}
	return;
}

使用例

ボタンのクリックイベント作成
image.png

Animation.gif

結果

・実行時にApplicationScale経由でウィジェットサイズを変えられます。
・ProjectSettingを実行時に変更して大丈夫なのか分かりませんが、一応パッケージ化しても動いてました。

バージョン:UE5.2.1

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