Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Render error when adjusting Main Camera's Viewport Rect

Discussion in 'Editor & General Support' started by bossagroove, Jul 6, 2014.

  1. bossagroove

    bossagroove

    Joined:
    Feb 13, 2014
    Posts:
    7
    I have a project that using custom Viewport Rect value and working well, until today I found that it's not

    I created a new project with a default camera, a default plane, some sphere and box
    absolutely no user scripts

    I then set the camera Viewport Rect to:
    X: 0
    Y: 0.25
    W: 1
    H: 0.5

    and build to Nexus 5,

    what I expected is: (Photoshop-ed to simulate the result, I see the same in Unity Editor)

    correct2.png

    and here is the screen capture from Nexus 5:

    wrong2.png

    I tried to build the project to Galaxy S4, same result.
    Surprisingly seems no one mention this on internet,
    I wonder if any setting of my unity editor go wrong:


    Environment:
    Unity Version: 4.5.1f3 @ Windows 7
    Android Platform, Min API Level 4.0
    Development Build and Script Debugging checked

    Androids:
    Nexus 5, Android 4.4.4, Dalvik (Default) Runtime
    GalaxyS4, Android 4.4.4 (Google Rom), Dalvik (Default) Runtime

    Is there anyone who can replicate the result? Thanks a lot
     
  2. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    I had a similar bug with custom viewport rect. In my case I was changing the viewport rect at runtime, on the home page its full screen and then in game the width and x value were adjusted with a gui column on the side. In the editor it was fine but when building to desktop or webplayer it had this issue. Using Unity 4.3 something or the other

    I can't tell from your static image whether it was exactly the same, as I changed the viewport the area which was supposed to be blank was not been cleared but it was not updating as the actual camera was , it seemed to be semi-frozen in one spot with a slight bit of jumping around in the same place.

    Sadly I did not find a cure ;( I was lucky and just created a solid background behind my gui column to cover the problem. I did not find anything on google , I tried various things.. enable , disable between changes resetting the layers , reseting the clear options .. nothing worked.
     
  3. bossagroove

    bossagroove

    Joined:
    Feb 13, 2014
    Posts:
    7
    Maybe I'll try different version of Unity to test, I think this is crazy as now I can't use custom Aspect ratio in my game. I can't use anything to just 'cover' the screen to act as letterbox, as seems that it will pick any other place in the scene randomly, and render it on the screen.

    I wonder if it's a bug of Unity Engine, as nothing is customized in the scene, all the things are default stuff. I can consider the 'viewport rect' option of camera is unusable now
     
  4. HDT Games

    HDT Games

    Joined:
    Jul 30, 2014
    Posts:
    2
    I have the same problem, building to Nexus7 and Galaxy S5, Unity 4.5. Found nothing on the net about it, much like you. I released a game last month, and was going to update to 4.5 from 4.3 prior to release but thought better of it, thank god i did because 4.5 totally broke it. Now starting another game, and I have the exact same problem. It seems its only an Android problem, and only when adjusting the viewport Rect. I may have to ditch 4.5 and stick with 4.3 until its fixed :(. Have you had any luck finding the cause or a solution?
     
    Last edited by a moderator: Aug 5, 2014
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Actually that's expected, and not a bug. When you use a single camera and reduce the viewport rect, the unused area is undefined. Might be black, might be garbage, or anything. So you need another camera underneath that draws what you actually want (such as solid black).
    http://wiki.unity3d.com/index.php?title=AspectRatioEnforcer

    --Eric
     
    hantengx likes this.
  6. HDT Games

    HDT Games

    Joined:
    Jul 30, 2014
    Posts:
    2
    Hi Eric,

    Thanks for the info, i just tried your suggestion and it worked perfectly, I can use 4.5 solely now, much appreciated.
     
  7. Kurius

    Kurius

    Joined:
    Sep 29, 2013
    Posts:
    412
    @Eric5h5
    I'm trying to get around the fact that the unused area is undefined. More specifically, here's my issue...
    I'm collaborating with a vendor who wants to put my game on their Android device, but they want to display their own custom vertical menu bar to the right of my game, on the right side of the screen. Their menu bar uses their own custom code (it does not use Unity). The vendor's Android device has a resolution of 1024x600. They're asking me to force my game to fit a resolution of 976x600, so that their menu bar can appear next to my game in the region of 976 to 1024. I've tried messing with the Viewport Rect settings, but the vendor's menu bar isn't showing up for some reason. Yet the vendor's menu bar shows up next to other people's games who have not used Unity to make their games. Any guidance would be much appreciated. Thanks
     
  8. MDurli

    MDurli

    Joined:
    Jul 16, 2014
    Posts:
    10
    Hello, I found your message because I'm having the exact same problem.
    The problem is that I started my project in Unity 4.6, were camera viewrect was working, and now I moved to Unity 5 were I'm experiencing the same problem you had in Unity 4.5.1.
    Here's my post:
    http://forum.unity3d.com/threads/ui...oid-when-camera-viewport-rect-changed.322406/

    Did you find any workaround?

    Thanks!