Author Topic: Zoomable clipped panel? (zoom in/out the contents)  (Read 3365 times)

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
Zoomable clipped panel? (zoom in/out the contents)
« on: September 13, 2013, 03:22:50 AM »
Hello,

I am looking for a way, if possible to zoom in/out to/of the clipped panel's contents.

Now I have done this before by using an external orthographic camera, changing its rect to the area I want to zoom in to, and then mess with its size to zoom in/out. (See attachment)

Now this is OK if I don't wanna interact with the object I'm zooming in/out to/from. Obviously for this to work, I had to make a separate panel for the object in question (the wooden sprite) - Got this info from UIWidget.cs:

  1.         public void CheckLayer ()
  2.         {
  3.                 if (mPanel != null && mPanel.gameObject.layer != gameObject.layer)
  4.                 {
  5.                         Debug.LogWarning("You can't place widgets on a layer different than the UIPanel that manages them.\n" +
  6.                                 "If you want to move widgets to a different layer, parent them to a new panel instead.", this);
  7.                         gameObject.layer = mPanel.gameObject.layer;
  8.                 }
  9.         }
  10.  

But then of course, when you mess around with layers (because I should remove the object I'm zooming in/out layer from my main gui cam culling mask, so that only my external cam sees the object - the wooden sprite), ray might not hit colliders, I had a lot of trouble getting the collider on the wooden sprite to detect mouse clicks, I rarely, in some very unique cases managed to, I was never able to get it work.

Anyway, that's not my question, I was just showing you my attempt to create a zoom in/out effect. I will post in much more detail about the problems I had there in another post.

But right now, since my way of doing it was very tedious, I thought well, NGUI must have something to achieve this, Aren wouldn't let something like this pass by now would he? ;-)

So, is there an NGUIsh way, an elegant way to achieve zooming in/out?

- Thanks all in advance.

EDIT: I have just noticed that messing around with the panel's scale (that has only the wooden sprite) could do the job for me, but of course, messing with a panel scale is a taboo in NGUI :(  (See other attachment)

« Last Edit: September 13, 2013, 03:34:50 AM by vexe »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Zoomable clipped panel? (zoom in/out the contents)
« Reply #1 on: September 13, 2013, 09:08:47 AM »
In NGUI 3 you can modify scales freely -- and in this case I'd advise scaling the game object underneath your scrollable panel (the root of your scrollable panel's content).

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
Re: Zoomable clipped panel? (zoom in/out the contents)
« Reply #2 on: September 13, 2013, 09:11:10 AM »
Thanks for the reply. I haven't upgraded yet. So I guess, even scaling the root of my panel's content won't help right? cuz there are children under it... :/