Hello Guest

Author Topic: Overrides and viewport  (Read 3169 times)

FreemanSwe

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Overrides and viewport
« on: June 29, 2014, 08:50:59 am »
Right now I have a background camera (tk2dCamera) that fills the screen with a solid color, then I have another camera (tk2dCamera) that has an override set as follows: wildcard, fit visible and center. This (the second) camera has depth +1 so that it is rendered after the first camera.

The second camera draws an image that fills the native resolution so I know that the override/stretching works exactly as I want to in different resolution (i.e. I get bars either at the top and bottom or at the sides when I should get them).

The problem I have is that when I change the resolution so that I get bars because of the override I can still draw sprites outside the cameras area/view (i.e. the second camera can draw sprites in the bars). I expected the second camera to clip the sprites to the cameras viewport/area automatically, but it still uses the entire screen and I can't find any settings to change this behavior.

I've tried setting the clipping with tk2dSprite.CameraSettings.rect but when I, for example, set x and width it doesn't clip the rendered image at the left side, instead it pushes it to the right and clips everything at the right side. I have bottom-left on my camera/sprite, maybe this is how it's meant to be.

EDIT: I just wanted to say that If I changed to Center instead of BottomLeft, the clipping works as it should (it clips at both the left and the right side).

But it feels wrong that I have to set the clipping when I've already defined the cameras area by using the override.

I've also made sure that it's only the second camera that is drawing the layer that my sprite (tk2dSprite) uses (the first camera has Nothing in the Culling Mask field).

BTW, I have implemented the fix in this thread to fix a problem I had in the build version of my game, but I've tried without this fix too and this problem still persists.
http://2dtoolkit.com/forum/index.php/topic,4103.msg19477.html#msg19477

I'm using Toolkit 2d v2.4 and Unity v4.5.1.f3.

Am I doing something wrong either with the camera, the clipping, or the sprites? Have I missed something? Any suggestions for a solution? :)

If you want an example project to show you my problem just tell me. :)
« Last Edit: July 01, 2014, 08:44:57 am by FreemanSwe »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Overrides and viewport
« Reply #1 on: June 29, 2014, 07:59:39 pm »
Thats a very comprehensive explanation but I don't think I understand exactly whats going on - whether this is working as expected or not. Please post an example in the private support forum.