Author Topic: UIScrollView sets clipping to SoftClip (undesired behavior)  (Read 10367 times)

PebbleBug

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
UIScrollView sets clipping to SoftClip (undesired behavior)
« on: November 25, 2013, 09:24:52 AM »
Hi,

Any particular reason UIScrollView sets the panel clipping to SoftClip in the Awake when the clipping was set to None?
In a particular case I want the clipping to be None so I'd rather it would just leave the setting alone. As a fix I commented out the code that changes it and nothing seems to break.

mimminito

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #1 on: November 25, 2013, 10:48:46 AM »
I am getting the same issue, was going to post this up today as well!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #2 on: November 25, 2013, 06:57:42 PM »
So just to clarify, you're using the scroll view script, but doesn't want it to clip? Can you explain how you're using it?

PebbleBug

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #3 on: November 26, 2013, 01:58:55 AM »
A big horizontal scrolling selector that doesn't need to be clipped. Also I don't want it to be clipped as this makes selecting and modifying clipped items in the editor using the scene view near impossible.

I could set a really big clipping rect, but that's just a workaround for wanting no clipping so I should be able to select no clipping.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #4 on: November 26, 2013, 03:50:56 AM »
Ok, try this... Add "Invisible" to UIDrawCall.Clipping enum:
  1.         public enum Clipping : int
  2.         {
  3.                 None = 0,
  4.                 AlphaClip = 2// Adjust the alpha, compatible with all devices
  5.                 SoftClip = 3,   // Alpha-based clipping with a softened edge
  6.                 Invisible = 4// No actual clipping, but does have an area
  7.         }
...then find UIDrawCallOnRenderObject function, and modify the if statement from:
  1. if (mDynamicMat != null && isClipped)
to:
  1. if (mDynamicMat != null && isClipped && mClipping != Clipping.Invisible)
Also change that line in UIScrollView.Awake to:
  1.                 if (mPanel.clipping == UIDrawCall.Clipping.None)
  2.                         mPanel.clipping = UIDrawCall.Clipping.Invisible;

PebbleBug

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #5 on: November 26, 2013, 04:21:55 AM »
Yes, works for me. Although from a user's perspective None and Invisible are indistinguishable from one another and it is unclear why I should use Invisble as the outcome is exactly the same as None.
Also with "Invisble" my first assumption is that it will always clip the content, the opposite of what it actually does.
"None" would be a much better name for it ;)

So, your suggestion technically works, but it is unclear why it is necessary as at first glance it seems to make things more confusing. (without -as a user- knowing or caring about what goes on under the hood)

mimminito

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #6 on: November 26, 2013, 04:40:02 AM »
Could you clarify what "None" does exactly? Because I am in the same boat, where when I upgraded to the new 3.0.6 NGUI, my clipping is ALWAYS set to Soft Clip when the game is run.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #7 on: November 26, 2013, 05:37:07 AM »
"None" means no clipping occurs. The latest uploaded version has the Invisible code in it.

PebbleBug

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #8 on: November 26, 2013, 06:17:13 AM »
Sorry, but that solution doesn't make sense to me at all.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #9 on: November 26, 2013, 06:18:58 AM »
I can't call it "None" because doing so would break backwards compatibility. I'm not sure what else to call it.

PebbleBug

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #10 on: November 26, 2013, 09:27:20 AM »
Yeah, I see your point. Maybe IgnoreClip is a better name, fits in with the other two states.

But in this particular case I think introducing an Invisble clipping state just for the UIScrollView is a bit overkill that adds more confusion than that is solves things. Unless you see other future uses for it.

If the UIScrollView code requires that a clipping rect is defined, I'd be perfectly happy to just receive an error or warning about this so I know what is going on can manually set a giant cliprect.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #11 on: November 26, 2013, 11:27:34 AM »
I remember a request or two for this in the past, where people wanted the content restriction without the associated clipping.

IgnoreClip wouldn't make sense to me as it wouldn't actually ignore clipping. Clipping is just not visible, but content still gets restricted.

PaulGregory

  • Guest
Re: UIScrollView sets clipping to SoftClip (undesired behavior)
« Reply #12 on: November 26, 2013, 12:59:30 PM »
I am a confused by the idea that using None to mean 'no visible clipping' would break backwards compatibility, given that there are people who used to use None and now it means 'change to SoftClip on run'. Surely that broke backwards compatibility?

Anyway, I agree that Invisible is confusing, so may I suggest a sensible name would be NoClip (partly on the grounds that this is a truncated version of how the comment describes it).