Author Topic: UIPanel.IsVisible considerations  (Read 7059 times)

serioustommy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
UIPanel.IsVisible considerations
« on: April 30, 2015, 06:16:16 AM »
Hi,

There are a few overloaded UIPanel.IsVisible, and they currently don't seem to be consistent in their checking criteria.

For example, IsVisible (Vector3 worldPos) and IsVisible (UIWidget w) take clipping into account, whereas IsVisible (Vector3 a, Vector3 b, Vector3 c, Vector3 d) don't.

The one I really need is to be able to know if a point is inside a panel or not, regardless of clipping type. Right now I can work around it by calling IsVisible(a, a, a, a) and supply the same point in the 4 parameters but I'm hoping that we could have a safer and clear way of doing it since that particular overloaded method could be "fixed" in the future to have the same clipping check.

In any case I think all IsVisible should be consistent in what checks and early outs they do before actually getting to evaluate the points.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel.IsVisible considerations
« Reply #1 on: April 30, 2015, 06:28:11 PM »
Why don't you just look inside UIPanel.IsVisible and use the same math from within? It's a few lines of code.

serioustommy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: UIPanel.IsVisible considerations
« Reply #2 on: May 01, 2015, 10:18:26 AM »
Sure I already considered that but the private fields in UIPanel makes it not possible.

I guess the next question would be why don't I just modify the NGUI source. We try to avoid modifying/branching any third party plugin just to avoid headaches merging and updating the plugins later on (I guess you've heard this one million times already). Obviously if we are doing major changes or refactoring to it then we'll do that but this change we feel is something that NGUI can incorporate very easily as an improvement.

Right now it just doesn't make sense that when checking a point it takes clipping into account but not when checking 4 points (a rectangle). Currently you need to read the source code to understand the distinction. Inconsistency is my key point here that makes the code as it stands more confusing than necessary.