Hello Guest

Author Topic: tk2dCamera not showing anything  (Read 3818 times)

Nicolinux

  • Newbie
  • *
  • Posts: 3
    • View Profile
tk2dCamera not showing anything
« on: February 18, 2013, 10:18:56 pm »
Hi,

I have the latest version of 2D Toolkit (1.9) as well as Unity (4.0.1). When I create a new project and delete the main camera, then add a 2k2dCamera and a sprite in front of it - it doesn't show anything. I know about the issue with the camera preview - that's not it. In the game view there is no object (regardless of the object type).

Did I overlook something obvious? This is a fresh project - I didn't change anything else.
I also tried it the other way around. Created a new project and set the Main Camera to orthographic. Then added a few objects. I can see them in the game view. But as soon as I add the tk2dCamera script to the Main Camera, the problem occurs.

Thanks,
Stefan

Nicolinux

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: tk2dCamera not showing anything
« Reply #1 on: February 18, 2013, 11:03:43 pm »
Ok, problem solved. I should have read the old camera tutorial. There it is stated that sprites should be placed at x:100, y:100.
Instead I have accessed the new documentation where this info is missing.

@unikronsoftware: Maybe you should add this very valuable piece of info to the new docs aswell.

By the way. I don't get the positioning of sprites. Why is a sprite with x:0 and y:0 centered on the tk2dcamera (scene view) but shows at bottom left in the game view? I would expect that a sprite that is centered there would also be centered in the game view. This offset would make it a pain to move sprites in the scene view.
I am still suspecting that there is something wrong...

Thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera not showing anything
« Reply #2 on: February 18, 2013, 11:13:01 pm »
There is something wrong - the Unity camera preview code doesn't respect custom projection matrices. Its the same reason the Unity camera preview doesn't show the correct view and I've had to add a tk2dCamera preview showing the correct output. I've filed a bug report to Unity but it hasn't been fixed yet - this happens in any case where there is a custom projection, eg. shadow maps, etc. Perhaps I should add another frame to show the bounds in scene view, it should help avoid situations like this.

The sprite doesn't HAVE to be placed at 100, 100 - if it were at 0, 0, it should appear at the bottom left of the screen. That is expected behaviour. If you need it to be centered on screen, you can create an anchor, or if the tk2dcamera doesn't work out for you, you can use an ortho camera too - the system works fine either way.

Nicolinux

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: tk2dCamera not showing anything
« Reply #3 on: February 18, 2013, 11:21:32 pm »
Thanks for the clarification. I know about bottom left beeing the origin but I find it weird to position objects in the scene view that way. In code that's no problem.
The problem I described in my first post was after moving sprites in all directions. Maybe it was just a temporary problem. I did restart Unity (and my Mac) and now it works.
I didn't knew about anchors - so thanks for that.