How do I use a fixed layout with Unity3d?

At the bottom of the following documentation it explains how to use fixed layouts for Windows Apps: Microsoft Learn: Build skills that open doors in your career

Does anyone know how to use the ViewBox control with Unity3d or another way to achieve a fixed layout?

Any help is appreciated.

Thanks,

Nathan

Hey Nathan,

I don’t think you want to confuse yourself by attempting to use the Windows API to achieve this. There are many plug-ins and techniques available in Unity-alone that will ensure pixel-perfect graphics (some coming for free in the new Unity 4.3). Google search “pixel-perfect Unity” and you’ll find a bunch of results:

http://pixelplacement.com/2013/01/03/pixel-camera/

By doing it this way, you will ensure it works across all platforms.

Jodon,

Thanks for the links. I’ve read through them and we are using an Orthographic camera, but we are not dynamically setting the camera size.

After the game has started, some game world objects are created at positions in the world. When the game is resized, or snapped, some of the elements are no longer visible. Do you know of any way to prevent the game from being resized or snapped all together?

Thanks!

you can’t, and for windows store apps you “must” support snap view state changes… it’s a requirement. Also, those requirements have changed slightly for 8.1, so you’ll need to handle snapping somehow… I think most people pause the game and show some kind of “hey, i’m paused” screen.

Just fyi, ViewBox is a XAML only element that permits scaling of its’ UIElements and is totaly unrelated to Unity. The SwapChainBackgroundPanel is the ‘drawing’ surface (if you will) for Unity… its’ a DirectX frame buffer and automatically scales to full screen (or full snapped area).

You could detect the snapped view state change, pause Unity, and handle the state change by changing the visibilty of your “hey, I’m paused” UIElement, … put that into a ViewBox that occupies the entire grid (if you are using grids for layout) and then your UIElements will scale within the bounds of the viewbox.