Dealing with resizable windows in store build

This is for Windows Store builds, not standalone PC builds.

I haven’t installed Windows 10 yet, so I can’t test this myself. Hoping someone can answer this for me. My main concern looking at the new Windows 10 feature list is that store/metro/modern apps can now live on the desktop inside of resizable windows. Up until now I’ve only had to worry about the “split screen” mode in Windows 8. I just pause my game and display a splash screen when in split screen mode, since I don’t want to worry about supporting other aspect ratio screen/window sizes. Will this approach still work using this code below?

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
    // ...Other template/default code here....

    // I add this line
    Window.Current.SizeChanged += Current_SizeChanged;
}

// I add this function.
void Current_SizeChanged(object sender, WindowSizeChangedEventArgs e)
{
    // GameManager is a class in my Unity project, and ForcePause is a static variable
    //  that other parts of my game use to "force pause" and display a splash screen.
    GameManager.ForcePause = Windows.UI.ViewManagement.ApplicationView.Value != Windows.UI.ViewManagement.ApplicationViewState.FullScreenLandscape;
}

The above code is from App.xaml.cs – the one Unity creates (I’ve been using it since Unity 4, haven’t actually tried with Unity 5 template changes). I just hook the Window SizeChanged event and set a flag on one of my game objects which I use to display a splash screen and force Time.TimeScale to 0.

Did you actually test that it doesn’t work with your current approach? I expect it should, as in Windows 10 you cannot resize apps below certain threshold (no idea about exact numbers).

I haven’t installed Windows 10 yet, so I can’t test this myself. I plan to upgrade one of my PCs so I can test in the future, but that might not happen for several weeks.

I guess as long as the SizeChanged event still fires in Win10, and the Windows.UI.ViewManagement values are still the same, then it should work.

I guess this might be a clue that it will no longer work:

That “not supported in future” merely means that apps targeting newer OS versions will not be able to use it. Microsoft doesn’t break existing apps, so you’ll be safe as long as you’re targeting Windows 8/8.1. When you upgrade your application to target Windows 10, then you might have to change something.

Awesome, thanks!

In my experience Unity games work exactly the same under Windows 10 as they do under Windows 8.1 (in Windows 8.1 the user can give your game an arbitrary window with, and Windows 10 forces a minimum height the same as Windows 8.1’s minimum). This is to be expected because Unity is outputting W8/W8.1 projects and Windows 10 is backwards compatible.

A technique I used on my game was to set a minimum width and display a popup (like you did for snapped view) if the screen width fell below this. I hooked into the Windows.Current.SizeChanged to do that. It works perfectly on Windows 10.

If you want your game to scale well on Windows (or any platform for that matter) I made an asset called Resolution Magic 2D that’s in the Asset Store and makes it easy.

Info here:

http://unity.grogansoft.com/resolution-magic-2d-what-it-does/

1 Like