Search Unity

Interesting article from Google on Android Hardware Scaler

Discussion in 'Android' started by Neogene, Sep 27, 2013.

  1. Neogene

    Neogene

    Joined:
    Dec 29, 2010
    Posts:
    95
    http://android-developers.blogspot.it/2013/09/using-hardware-scaler-for-performance.html


    Java:
    Code (csharp):
    1. surfaceView = new GLSurfaceView(this);
    2. surfaceView.getHolder().setFixedSize(1280, 720);
    Code (csharp):
    1. int32_t ret = ANativeWindow_setBuffersGeometry(window, 1280, 720, 0);
    2.  
    Does someone knows if Unity already uses this feature?
     
  2. Chris-Clark

    Chris-Clark

    Joined:
    Jan 16, 2012
    Posts:
    130
    That's what I just came here to ask. Does Unity Free allow you to render to a smaller resolution? With all these extremely high DPI devices coming out, it's not always best to render full res.
     
  3. Chris-Clark

    Chris-Clark

    Joined:
    Jan 16, 2012
    Posts:
    130
    I did some research and found something similar. I'm not sure if it uses the Hardware scalar the article talking about or if Unity just renders to an offscreen surface, but either way you should get some performance improvements if you drop down to 720p on a 1080p phone or higher.

    http://docs.unity3d.com/Documentation/ScriptReference/Screen.SetResolution.html

    Use that and set it to fullscreen and it should scale. I'm not at my development machine though, so I can't test it yet, but you should play with it to see how it handles multiple resolutions. It says it will try and match the closest one but I think it would be better if you grabbed the hardware info and set the resolutiona ccordingly to make sure you have the correct aspect ratio. And for unnecessary scaling as would be the case of a 768p phone, you don't want to scale to 720p. Might actually lose more than you gain because of the scaling function.

    You should also remember to scale your UI according to the device DPI using Android's DP (device independent pixels) you can look up the math on the Android dev site. This way a menu that is the right size on a 720p phone will not be insanely large on a 720p tablet, you need to draw it much smaller on the tablet. Using Android DPs you can get a menu that is physically the same size on all screens regardless of resolution and screen size.

    That all would have to be custom code in your GUI system.
     
  4. bitter

    bitter

    Unity Technologies

    Joined:
    Jan 11, 2012
    Posts:
    530
    Yes, using Screen.SetResolution() will use the hardware scaler.
     
  5. nahoy

    nahoy

    Joined:
    Dec 10, 2012
    Posts:
    21
    Awesome!

    Is it also working on iOS? I mean does Unity handle something similar?

    Thanks.
     
  6. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    Screen.SetResolution() also works with iOS.