HTML5 Resolution/Canvas Size

I’ve made a HTML5 build of my game with a small button on the lower left corner of the HUD through C++
This button is meant to make the game FULL SCREEN, instead of using the HTML button.

I’ve tried using

GSystemResolution.RequestResolutionChange(1920, 1080, EWindowMode::Fullscreen);

and

GetOwningPlayerController()->ConsoleCommand("r.SetRes 1920x1080f");

However i keep getting this message:

Warning: Console variable 'r.SetRes' wasn't set (Priority Console < Code)

Any Ideas?

Cheers

This is pretty subtle. Basically, there’s many different ways to set console vars in UE4: .ini files, Editor settings, C++ code, debug console in-game, etc. Because of this, users/developers sometimes set conflicting values on the same console variable.

UE4 solves this problem by assigning different priorities to each method. For example, say you set your resolution to X1,Y1 in C++ code. Later, you try to r.SetRes to X2,Y2 in the in-game console (or the PlayerController->ConsoleCommand function, which is equivalent). Your call to r.SetRes will fail, because console variables set through C++ code take priority over those set using the in-game console.

You can see a comprehensive list of the different priorities here: https://docs.unrealengine.com/latest/INT/Programming/Development/Tools/ConsoleManager/index.html#priority

You’ll probably want to do something like this instead:

 IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SetRes"));
 CVar->Set(res);

This will allow you to access and update the r.SetRes console variable directly, with the same priority as other C++ code.