Saturday, March 19, 2016

if (900 != 900) { SomethingIsStrange(); }

Ok, I have a question for the other dev interns.  I had this problem when I first started the project, but I have consistently ignored it until now.

I have set the Unity window resolution to 900px by 600px.  Easy enough, right?  The only problem is . . . the screen size isn't 900x600.  I even took a screenshot and measured the pixels in MS paint.  It's more like 1350 by 900.



The blue is my actual window size.  You can see in the top left that it's saying my screen size is 900x600, but that's clearly false.  The same thing is also occurring in the web build.  It does happen to be the same ratio of width/height (3/2). So either Unity is just increasing my size by 50%, or Unity can't count, or I'm losing my mind.  I've used the usual google fu abilities, but I can't find anything about this issue.  Vox said he might have recalled someone else having this same problem.  Assistance/explanations are greatly appreciated.


Update:
Christoph Nahr suggested changing the DPI settings, and that worked fine.  I also found another quick fix for the web player.  It turns out that Internet Explorer was set at a 150% zoom for some reason.  I changed that back to 100%, and I'm back in business.  Don't we all love IE...


5 comments:

  1. I don't know Unity but almost certainly your Windows system has its DPI scaling set to 150%, so Unity correctly enlarges any specified coordinates accordingly. If you're unfamiliar with the concept, read High DPI Settings in Windows:
    http://www.kynosarges.org/WindowsDpi.html

    ReplyDelete
    Replies
    1. Thanks a bunch, that fixed the issue. I'll post in the comments if I have any more problems with this, but looks good for now.

      Delete
  2. Unity's screen size stuff is also wonky. This is because it prefers to work in relative coordinates so that it fluidly adapts to multiple resolutions. Which is nice in theory, but a lot of times absolute screen coords are nicer, especially in 2D.

    This is one of the many reasons I applied for the internship as an artist rather than a programmer. I dislike trying to wrangle Unity's screen sizing.

    I ended up hitting this problem anyway when I built Vargenstone's title screen. The screen was made with the exact resolution in mind -- no bleed over. Positioning the graphics onscreen so that they filled the screen at the right resolution was a pain. Then, making the exported game actually display the right resolution was wonky.

    Interestingly enough, the HTML5 engine only seems to work in Pale Moon (and theoretically Firefox) for me.

    My solution to these problems? Let Portable Supernova worry about them unless and until he asks me to tweak the art to suit his solution. >:D

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hello, Daniel!

    I am a noob Unity Developer. This article is quite informative.
    Thanks for sharing.

    ReplyDelete