I always need to set the Widget Reflector APplication Scale when I open the editor because I have 4K monitors, and otherwise the text is all too small to read. Can I automate that process by putting a command in an init_unreal.py file? Does anyone know the command I would need?
I’m answering my own question here. I solved this by wrapping the function that sets the application scale in a blueprintable function. Then I call it from python in a file that has to be named init_unreal.py for Unreal to run it on startup. init_unreal.py must be in the /Content/python/ folder (make it if it does not exist), or some other folder that is in the Editor’s python path. Here is the code:
.cpp
#include "GPSetApplicationScale.h"
#include "Framework/Application/SlateApplication.h"
void UGPSetApplicationScale::SetScale(float Scale)
{
FSlateApplication::Get().SetApplicationScale(Scale);
}
.h
#include "GPSetApplicationScale.generated.h"
UCLASS(Blueprintable)
class GRANDPA_API UGPSetApplicationScale : public UObject
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category="Smoketests")
void SetScale(float Scale);
};
init_unreal.py
unreal.GPSetApplicationScale().set_scale(1.4)
1 Like