Hello Guest

Author Topic: Normalized View Port Rect multiple devices  (Read 6767 times)

mangoocean

  • Newbie
  • *
  • Posts: 25
    • View Profile
Normalized View Port Rect multiple devices
« on: November 05, 2014, 03:06:37 am »
Hi,

I've read through the documents and forums but still very confused on how to ensure my normalised view port on my camera changes to suit each resolution/ration of all devices (iPhone 4s, 5, 6, Android).

it's important that I keep the rectangle the same on each device. My default camera is 1080x1920.

Should I be using an override?

Thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Normalized View Port Rect multiple devices
« Reply #1 on: November 05, 2014, 11:50:00 am »
What are you trying to do? It might be easier to just use a normal unity camera here, but I can't advise until I know what you're trying to do here.

mangoocean

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Normalized View Port Rect multiple devices
« Reply #2 on: November 05, 2014, 09:52:17 pm »
Sure thing

I used a normalised view port to contain the game elements - it acts as a frame for the game. Therefore nemies enter the game "screen" (frame) and exit without having to go off-screen.... erm... am I making sense? Just woke up.

So for example, take Tetris. You have blocks falling from the top of the "game screen". You don't want these blocks appearing until they enter the "game screen", rather than having them fall from "device screen" at top.... as you may have scores and other stuff going on around the 'game screen'. OK, I'm babbling. Hope this makes sense.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Normalized View Port Rect multiple devices
« Reply #3 on: November 06, 2014, 10:01:21 am »
Ok. What makes this complicated is the rescaling tk2dCamera does. If you don't need the rescaling use a normal camera instead.
One really easy way to work around this is to add solid (be sure its a solid shader) sprite or box to create your game frame. Or if you have some graphics for this, draw this in front of your game objects... basically you can do this without camera trickery and these things would just work at different resolutions / scaling as they arent tied to the camera.

mangoocean

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Normalized View Port Rect multiple devices
« Reply #4 on: November 07, 2014, 09:27:59 am »
OK, I think I get what your'e saying - using this sprite shader in replacement of a normalised camera. I'll give it a shot, thanks.

mangoocean

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Normalized View Port Rect multiple devices
« Reply #5 on: November 07, 2014, 09:28:51 am »
Quick question about this method - would this have a big impact on draw calls?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Normalized View Port Rect multiple devices
« Reply #6 on: November 07, 2014, 10:44:59 am »
What I mean is add 2 or 4 cubes with a solid shader in front of everything to letterbox. It should add 1 draw call, and being solid it will be drawn before everything else.