Hello Guest

Author Topic: 2dtk Camera Stretching Everything  (Read 5741 times)

B1ueman123

  • Newbie
  • *
  • Posts: 4
    • View Profile
2dtk Camera Stretching Everything
« on: April 30, 2014, 05:58:04 pm »
I love 2D Toolkit! It's a lifesaver in so many ways, I can't imagine what I would have done without it. With that said, I've been programming a standalone 2D PC release on Unity for about 6 months, and I've kept putting off the issue that when the game is played in Fullscreen mode, it stretches everything  :-[ to the screen's resolution. I've looked around forums for an answer, but most of Unity's camera forums deal with the main camera automatically set in a Unity scene. I've read about the overrides and can't seem to figure this one out. Here's all of my settings, because at this point, there's so many things set to 1024x768, I'm hopefully creating the problem myself.





This code has bounced around multiple programmers in the project and it's hard to tell who did what, where. Any help would be so much appreciated! Ideally, I just want the game to have the 4:3 Aspect ratio in fullscreen. No stretching, even if it doesn't get any larger, but just stays centered with a border around the whole thing, similar to Binding of Isaac.
Thanks so much,
Josh

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2dtk Camera Stretching Everything
« Reply #1 on: April 30, 2014, 09:36:13 pm »
The override "Match By" should be set to wildcard, everything else seems sensible.
What resolution does it look wrong on?

B1ueman123

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: 2dtk Camera Stretching Everything
« Reply #2 on: April 30, 2014, 11:45:32 pm »
When it comes up with the resolution dialogue selector, I choose 1024x768 and allow it to not be in window mode. When it begins, it fits to my screen resolution, which is 1920x1080, but stretches everything in the game to fit this resolution. Is there anyway to tell it not to do that, and keep it in 1024x768, so it doesn't stretch?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2dtk Camera Stretching Everything
« Reply #3 on: May 01, 2014, 11:24:27 am »
In the dialog selector, you choose 1028x768? That'll be your monitor upscaling to its native resolution, you can't do anything about that apart from possibly some settings on your monitor.

You should pick a resolution that matches the aspect ratio of your monitor, otherwise you end up with non-square pixels and other horrible things like that. The tk2dCamera settings are fine, you just need to pick a resolution that your monitor doesn't stretch to fill the screen while ignoring the aspect ratio...

B1ueman123

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: 2dtk Camera Stretching Everything
« Reply #4 on: May 01, 2014, 04:30:57 pm »
Ahhh that makes a lot of sense! Thank you so much! That eliminates the stretching issue, but then it creates a different one that I'm sure the 2Dtk Camera is set to handle. I have UI elements on each corner of the screen. When the resolution changes, you can see a lot more of the level and beyond the 1024x768 box that is created by the UI Elements. What would be the best way to eliminate seeing beyond that? Possibly make all of that space black?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2dtk Camera Stretching Everything
« Reply #5 on: May 01, 2014, 06:05:09 pm »
The easiest way to do that would be to create 2 black sprites (tiny 4x4 sprites scaled up will do the job) positioned to obscure it. There are much more complicated ways to do this, but this is easy and you have full control

B1ueman123

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: 2dtk Camera Stretching Everything
« Reply #6 on: May 02, 2014, 12:00:46 am »
Awesome! Yeah, someone recommended that I use http://wiki.unity3d.com/index.php?title=AspectRatioEnforcer to fix that. I tried to implement it, and it didn't seem to do anything? Is there any reason why that script wouldn't work inherently with the 2D Toolkit Camera, like any other camera?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2dtk Camera Stretching Everything
« Reply #7 on: May 02, 2014, 12:19:59 pm »
That won't work with the tk2dCamera - the tk2dCamera controls the camera component, as does this, they both try to overwrite the same values. You can use that with a normal unity orthographic camera - that should work as expected.