Author Topic: Enabling Clipping on a UIPanel?  (Read 9371 times)

Jwkim

  • Guest
Enabling Clipping on a UIPanel?
« on: September 27, 2012, 04:17:20 PM »
Hi,

I'm using NGUI 2.2.0 for a mobile game.
We're using UIDraggablePanel for a vertically scrolling menu and it works great, except I can't limit its movement.
I read that "Restrict within Panel" should do the trick, but it only works if the panel's clipping area is defined.
But I can't seem to find the option to change the clipping area anywhere in the inspector for UIPanel.

Where can I adjust a panel's clipping area? Does it have to be done through code?

Thanks,

JW

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #1 on: September 27, 2012, 04:30:00 PM »
.. you srs?

See my attachments. If you are confused, follow the arrows.  :D

Jwkim

  • Guest
Re: Enabling Clipping on a UIPanel?
« Reply #2 on: September 27, 2012, 04:33:26 PM »
I don't see those options.
I just see check boxes for Show In Panel Too, Generate Normals, Depth Pass and Widgets Are Static.
Should I reimport NGUI?

Jwkim

  • Guest
Re: Enabling Clipping on a UIPanel?
« Reply #3 on: September 27, 2012, 04:45:09 PM »
I've tried updating NGUI, using the button in the Asset Store as well as creating a new scene and deleting then reimporting NGUI.

I still can't see those options for UIPanel. What should I do?

Jwkim

  • Guest
Re: Enabling Clipping on a UIPanel?
« Reply #4 on: September 27, 2012, 05:11:51 PM »
Turns out that there was another Editor script overriding UIPanel's inspector view. Doh! ><

Thanks.

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #5 on: October 03, 2012, 03:46:15 AM »
Hi,

Looking at the code, it seems it should work to set a clipping mode, modify the clipping area, revert to clipping mode = None and have the constraints work as expected.

Shouldn't the clipping area be renamed to bounds, and be always visible in the inspector, whatever the clipping mode ? Still looking at the source code, the clipping area is often referred to as bounds in the comments...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #6 on: October 03, 2012, 06:52:33 AM »
Clipping implies clipping widgets visibly -- exactly what the option does.

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #7 on: October 03, 2012, 08:16:46 AM »
The fact is that constraints only work if an area is defined, and they do not really need a clipping area to make sense.
To the contrary, it makes sense to clip a panel to its bounds.
So what is actually the clipping area (only visible when clipping is enabled, but always effective) could be renamed bounds, and always visible.

A side effect : if you want to implement something that resembles an iOS's table view, and if you don't know that clipping area remains once set even if clipping is disabled, you're required to enable hard clipping, which is very GPU intensive on most mobile devices because of full screen blending / discarding.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #8 on: October 03, 2012, 08:54:53 AM »
A panel is just a container. It merely collects all widgets inside it into a single draw call. Clipping specified on the panel is an effect related to drawing, which is why it's specified on the panel. You seem to think the panel has bounds, when in fact it does not. It's just an abstract widget collector.

If you want bounds, create a sliced sprite and use it as your background. You can then specify this sliced sprite to be your bounds, assuming you were talking about specifying it for something like UIStretch / UIAnchor.

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #9 on: October 03, 2012, 09:44:21 AM »
Ah, I should have mentioned, the problem shows up when using UIDraggablePanel, that uses UIPanel's clipping area as a constrain area.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #10 on: October 03, 2012, 07:36:17 PM »
Draggable panel script adjusts the clipping area. Using it as a constraint is like a loop. How can you adjust something that's constrained to itself?

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #11 on: October 04, 2012, 03:09:53 AM »
Looking at UIDraggablePanel's code, line 244 of v2.2.2, constraints are computed using the panel's CalculateConstrainOffset method, which in turns uses the clipping area / softness.

I did not look any deeper and may be completely wrong, but it looks like the draggable panel's constraints are panel's clipping area dependent, except that one could need a draggable panel tied to an unclipped panel (see example in one of my previous post).

mdeletrain

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 71
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #12 on: October 15, 2012, 10:04:27 AM »
Any other thought about this ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Enabling Clipping on a UIPanel?
« Reply #13 on: October 15, 2012, 01:53:36 PM »
Nope, no thoughts.