Hello Guest

Author Topic: tk2dCamera and Unity Camera  (Read 6137 times)

aphexyuri

  • Newbie
  • *
  • Posts: 14
    • View Profile
tk2dCamera and Unity Camera
« on: April 26, 2013, 09:36:38 pm »
Hi,

I have a game using the standard Unity camera, and the Unity OnGui for the HUD.

I now want to migrate the HUD to tk2d, in order to have elements anchored to the edges of the screen. I tried to add a tk3dCamera, to render at a higher depth as the main Camera, but the game is just rendering with default blue background, and 'old' scene at the bottom left. (see attachment)

Any pointers on how to accomplish this?

juts

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: tk2dCamera and Unity Camera
« Reply #1 on: April 27, 2013, 12:42:30 am »
Im realy new at this too, but if i had to guess i'd say its because your ortho size is likely incorrect (Needs to be half the height of your targeted resolution), and you haven't adjusted for the tk2d camera using pixels as world units.  setting a cube at 100,100,0 for example would put it 100 pixels right, 100 pixels up from the bottom left hand corner of the camera. Add a few test objects to get yourself oriented maybe?

aphexyuri

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: tk2dCamera and Unity Camera
« Reply #2 on: April 27, 2013, 12:58:48 am »
I've played around with the ortho sizes, but no luck.

One thing to note...the goal would be to have the standard Camera renders the scene as it was (content to left bottom of screen), and have the tk2dCamera only render the HUD elements (by using layers).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera and Unity Camera
« Reply #3 on: April 27, 2013, 09:50:01 am »
1. Set layers on objects +  correctly so the fist one draws into the normal camera, and the second into the tk2dCamera only. Disable each camera in turn to make sure each is only drawing what it needs to. At the end of it, remember to re-enable both.

2. Make sure the depth on the second camera (presumably the tk2dCamera) is higher than the first.

2. Set clear mode on the second camera to depth only.

They both should draw properly now.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: tk2dCamera and Unity Camera
« Reply #4 on: April 27, 2013, 09:51:03 am »
Check sample 6 as well - that has this set up correctly on there.

aphexyuri

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: tk2dCamera and Unity Camera
« Reply #5 on: April 27, 2013, 03:20:33 pm »
Great! I was missing the Depth Only setting - works well know.

As always, thanks!