Hello Guest

Author Topic: [SOLVED] Camera Stacking and Input detection  (Read 4154 times)

FIENDISH

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
[SOLVED] Camera Stacking and Input detection
« on: June 21, 2013, 11:25:14 pm »
Hi all,
new to 2DTK, but not to Unity so bear with me.

I am making a game where I need to zoom in and out, but also wanted to use 2DTK's automagic resolution detection etc.

So I stacked 2 cameras, a normal orthogonal one for zooming and camera movement, and a 2DTK camera for GUI anchoring and resolution detection.

The Gui Sprites are on a separate layer so I cull differently for each camera, 2DTK's camera depth set to 1, Don't Clear etc.

So far so good! The zoomy camera stuff works well, the 2DTK camera positions everything beautifully with no performance hit at all.

The problem: although I can detect objects for mouse/touch input on the Orthogonal camera with Raycasting, I cannot seem to 'also' click on the GUI stuff under the 2DTK camera.

I have tried several things using 2DTK's UI manager, using GUItextures, but cannot seem to make it work.
There must be some easy way to detect the 2DTK camera assigned layer sprites.

Further info: The orthogonal camera is set as the Main camera, It's a physics game.

btw can I suggest in the many button variations in your UI manager you make one that is just a plain quad, for mobile games to have a minimalist sprite-like one would be popular I'm sure.

Well I hope someone can help, so far I am really liking 2DTK, the atlas generation, slicing and dicing is great! Thanks in advance.

« Last Edit: June 24, 2013, 03:02:08 am by FIENDISH »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Camera Stacking and Input detection
« Reply #1 on: June 22, 2013, 08:53:36 pm »
First thing to check. Seeing that you're using the GUI stuff on a tk2dCamera, and the size obviously varies significantly from the default 1 ortho camera size, have you checked that the colliders have been resized to accomodate? Select a UI element, button or whatever, and then select the menu item: "2D Toolkit > UI > Fix selected item bounds". This should resize the bounds to fit the new camera. ps. you can multiselect to fix this on everything at once.

You can simply switch sprite types really easily - select the sliced sprite, and then click on the little cog icon next to the help icon on the component (i.e. on the far right to Tk 2d Sliced Sprite), and convert to sprite, etc.

FIENDISH

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: [SOLVED] Camera Stacking and Input detection
« Reply #2 on: June 24, 2013, 03:03:27 am »
Thanks Unikron - the sprite conversion fixed it.  :D