Author Topic: Clipping panel problem not found in FAQ  (Read 7585 times)

amykaroline

  • Guest
Clipping panel problem not found in FAQ
« on: June 21, 2013, 06:45:42 PM »
Hi All!

I have a weird problem trying to implement a UIDraggablePanel with Clipping.  I am almost certain it's related to shaders but I've spent a couple days on it and not figured it out - maybe you can help me.  Here's the set up in the scene:
UIRoot(2d) (with UIPanel) > Camera > Anchor > Panel (with UIPanel and UIDraggablePanel script attached, also a DeckManager script attached) > Grid

The Deck Manager script programmatically fills the Grid with Cards at runtime.  The cards are all widgets. Cards scroll but do not get clipped.  When I set the clipping to Alpha, Hard, or Soft, all of my cards disappear.  All the cards are in a single atlas at the moment.  The shader set on the atlas is "Unlit/Transparent Colored".  If I set the shader on this atlas to "Unlit/Transparent Colored Overlay" instead, the cards appear while clipping is on, however, they do not clip softly.  I guess that part's obvious, but it shows that this is something with the shader for sure. It's not finding the Soft Clip shader for some reason.  The NGUI shaders are all inside my Resources folder.  I compared the "Unlit/Transparent Colored (SoftClip)" to the shader I have in a project where the clipping is working properly, and the shader code is the same. 

Other things in the FAQ that I checked are as follows:
1. Check to make sure that you have shaders turned on. This means NOT targeting GLES 1.1, and NOT having your quality set to Fastest.
-- I am building to target iOS, so the Fastest setting doesn't seem to apply.  Still, I set my Quality settings as high as possible for Default.  Also, In Edit>Graphics Emulation> I selected GLES 2.0.

2. Make sure that the atlas used by your widgets is using the Unlit/Transparent Colored shader. If you have Simple Textures (UITextures) in there, make sure that they too use this shader.
-- Yes, this is set for the atlas.  I do not see a shader setting for the individual textures.  I have them all set to Advanced and TrueColor format.

3. Make sure the clipped panel uses uniform scale: (1, 1, 1).
-- Yes, the panel and the grid are both scale (1,1,1).

4. Your widgets that you want clipped must not have an extra panel in between of them and the clipped panel. Open the Panel Tool, select one of your widgets that should be clipped, and note which panel gets highlighted in the Panel Tool. If it's not your clipped panel, then you have an extra panel in there that you should remove.
-- Yes, I checked this in the panel tool and the panel selected for each card is the clipped panel.

5. Make sure that the shaders can be loaded properly. Did you move the NGUI's Resources folder somewhere?
-- Hmmm. Not sure. How do I check that shaders can be loaded properly?  This is probably the problem, but they are in the Resources folder.  Isn't that right? 

Is there some way I can check what shaders are being used by each object?  I am rather new to Unity so I'm not sure that's how it works, but I think that would be helpful if I could check them by debug logging. 
Any ideas friends?  Thanks in advance for your help!




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clipping panel problem not found in FAQ
« Reply #1 on: June 22, 2013, 06:38:59 AM »
Yup, select the panel and switch it from Gizmos to Geometry debugging. You can then select actual generated meshes, which will tell you what material & shader they are using.

Note on #3: It's not just the panel that you need to check. All parents leading up to the panel except UIRoot need to have uniform scale. Easiest way to force it -- select UIRoot and hit ALT+SHIFT+P.

Post a pic of your setup and the scene view, it might help.

amykaroline

  • Guest
Re: Clipping panel problem not found in FAQ
« Reply #2 on: June 24, 2013, 01:29:44 PM »
OK, I tried both things - the shader selected in the DrawCall is Unlit/Transparent Colored (SoftClip) and selecting UIRoot and hitting Alt+Shift+P didn't change anything, but I did try it and run the game.

Attached are two screenshots - one of my set up in the scene showing Panel 2 (the clipping panel) and the Grids inside it.
Second Screenshot is of the Scene with the UIDrawCall selected in the Inspector.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clipping panel problem not found in FAQ
« Reply #3 on: June 25, 2013, 01:21:32 PM »
Your screenshots don't work... likely because they are of "tiff" type. You should use JPG or PNG formats.

amykaroline

  • Guest
Re: Clipping panel problem not found in FAQ
« Reply #4 on: June 25, 2013, 01:39:02 PM »
Thanks and sorry about that.  Hope this helps - they are now PNGs.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clipping panel problem not found in FAQ
« Reply #5 on: June 25, 2013, 02:09:19 PM »
You need to bring your clipped panel forward (set transform position.z to -1).

amykaroline

  • Guest
Re: Clipping panel problem not found in FAQ
« Reply #6 on: June 26, 2013, 11:55:45 AM »
I wish it were that simple...
Changing the z transform on Panel2, Grid, and the widgets inside the grid, has no effect on the visibility of the widgets.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clipping panel problem not found in FAQ
« Reply #7 on: June 26, 2013, 12:30:39 PM »
And if you disable the background widget covering them? Do you see them then?

amykaroline

  • Guest
Re: Clipping panel problem not found in FAQ
« Reply #8 on: June 26, 2013, 01:41:54 PM »
AHA!
I had compared the shader code of "Unlit/Transparent Colored (SoftClip)" to the same code in another one of my projects (in that project, softclip is working beautifully), and the code looked the same, but I must have missed something. (did not do a diff, just compared visually, my bad)

I decided to try replacing the shaders in this project with the ones from that project, reimport, and see if it made a difference.  It immediately works beautifully! Yay!

Thank you for trying to help - something must have been changed in the shader code that I inherited.   I inherited this project from other developers...who I am not able to contact because their company dissolved and the owners had some sort of "bad experiences" with them. 
ANYWAY, taking on old code is always full of surprises.

Thanks again.