Search Unity

How do I use a fixed layout with Unity3d?

Discussion in 'Windows' started by Naethyn, Nov 5, 2013.

  1. Naethyn

    Naethyn

    Joined:
    Nov 5, 2013
    Posts:
    4
    At the bottom of the following documentation it explains how to use fixed layouts for Windows Apps: http://msdn.microsoft.com/en-us/library/windows/apps/hh465349.aspx

    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
     
  2. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    434
    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://indiehoodgames.wordpress.com...t-calculator-for-orthographic-camera-unity3d/
    http://pixelplacement.com/2013/01/03/pixel-camera/

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

    Naethyn

    Joined:
    Nov 5, 2013
    Posts:
    4
    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!
     
  4. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109

    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.