Author Topic: Scrollview items errors when located outside clipping range  (Read 5417 times)

kittikun

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 46
    • View Profile
Scrollview items errors when located outside clipping range
« on: December 18, 2013, 03:57:57 AM »
Hi all,

I have noticed that items clipped by a scrollview panel would output errors. The errors do disappear when clipping is forced to none.

Errors are the following type:

Quote
Invalid parameter because it was infinity or nan.
UnityEngine.BoxCollider:set_center(Vector3)
NGUITools:UpdateWidgetCollider(BoxCollider, Boolean) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:291)
UIWidget:ResizeCollider() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:565)
UIWidget:OnValidate() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:675)
UISprite:OnValidate() (at Assets/NGUI/Scripts/UI/UISprite.cs:293)

Quote
dest.radius>=0.0f
UnityEngine.BoxCollider:set_size(Vector3)
NGUITools:UpdateWidgetCollider(BoxCollider, Boolean) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:292)
UIWidget:ResizeCollider() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:565)
UIWidget:OnValidate() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:675)
UISprite:OnValidate() (at Assets/NGUI/Scripts/UI/UISprite.cs:293)

Quote
dest.radius>=0.0f
UnityEngine.BoxCollider:set_center(Vector3)
NGUITools:UpdateWidgetCollider(BoxCollider, Boolean) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:291)
UIWidget:ResizeCollider() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:565)
UIWidget:OnValidate() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:675)
UISprite:OnValidate() (at Assets/NGUI/Scripts/UI/UISprite.cs:293)

If you look at the scene view, you will see that items aren't drawn with any clipping mode except none.

To reproduce this, just create a scrollview with a lot of items, going beyond your scrollview area and also the main panel area.

This is not happening with the samples and I cannot figure what could be different with my scene


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #1 on: December 18, 2013, 12:17:50 PM »
Please update to the latest version before posting about issues. This was already fixed a while ago.

mikemvpi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #2 on: January 09, 2014, 11:35:04 AM »
I'm having this issue in a fresh project with NGUI v3.0.8 f7

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #3 on: January 09, 2014, 06:44:11 PM »
Can't say I've seen this in a while. Not since it was fixed weeks ago. Since you say you're still running into it, can you put some Debug.Log statements into the NGUITools.UpdateWidgetCollider function to see what it's doing and why the size ends up being zero?

mikemvpi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #4 on: January 10, 2014, 04:23:29 AM »
As far as I can say after some debugging, the first error message
Quote
Invalid parameter because it was infinity or nan.
UnityEngine.BoxCollider:set_center(Vector3)
NGUITools:UpdateWidgetCollider(BoxCollider, Boolean) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:296)
UIWidget:ResizeCollider() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:645)
UIWidget:OnValidate() (at Assets/NGUI/Scripts/Internal/UIWidget.cs:766)
UISprite:OnValidate() (at Assets/NGUI/Scripts/UI/UISprite.cs:354)
is caused by w.drawingDimensions returning Vector4 of NaNs.

And this is because of division in UISprite.cs lines 561-562. Checking the UISprite.mSprite structure reveals that all ints are zeros, and name is "Sprite".

So it seems that some kind of initialization did not happen. I assume that later errors are just consequences.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #5 on: January 10, 2014, 05:44:40 PM »
That is highly odd. How do you get widgets yo have width and height of zero? They are initialized with default values of 100, and it's not possible to change them to get lower than 2 via any known means.

mikemvpi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #6 on: January 11, 2014, 06:16:24 AM »
Hi, I did not mean that widget itself has width/height of zero. It's the UISprite.mSprite.width (height) that are zero for some reason.

I.e. while the UISprite.mSprite pointer is not null, the values of all it's int fields are zero. So following the UISprite.drawingDimensions code
  1. public override Vector4 drawingDimensions
  2.         {
  3.                 get
  4.                 {
  5.                         Vector2 offset = pivotOffset;
  6.  
  7.                         float x0 = -offset.x * mWidth;
  8.                         float y0 = -offset.y * mHeight;
  9.                         float x1 = x0 + mWidth;
  10.                         float y1 = y0 + mHeight;
  11.  
  12.                         if (mSprite != null)
  13.                         {
  14.                                 int padLeft = mSprite.paddingLeft;
  15.                                 int padBottom = mSprite.paddingBottom;
  16.                                 int padRight = mSprite.paddingRight;
  17.                                 int padTop = mSprite.paddingTop;
  18.  
  19.                                 int w = mSprite.width + padLeft + padRight;
  20.                                 int h = mSprite.height + padBottom + padTop;
  21.  
  22.                                 if (mType == Type.Simple || mType == Type.Filled)
  23.                                 {
  24.                                         if ((w & 1) != 0) ++padRight;
  25.                                         if ((h & 1) != 0) ++padTop;
  26.  
  27.                                         float px = (1f / w) * mWidth;
  28.                                         float py = (1f / h) * mHeight;
  29.  
I am getting w and h to be zeros, and therefore px and py are NaNs.

I have troubles getting why the mSprite object contains these uninitialized state. Looks like it's fields are having the default values from initializers and that's all. I tried debugging the code, but I was not able to find any case where mSprite is assigned with invalid object, or mSprite.width is set to 0. So I'm pretty much puzzled right now.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #7 on: January 11, 2014, 06:08:26 PM »
I would be very curious to know this as well. You can work around it by changing that "if" statement to:
  1. if (w > 0 && h > 0 && (mType == Type.Simple || mType == Type.Filled))
...but that just masks the problem rather than gets to the bottom of it.

matdru

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #8 on: January 13, 2014, 08:42:10 AM »
Hi,

I'm having same issue after i upgraded to the newest version ( it didnt occur previously ). Same errors and so on. Funny thing is, i have 6 Headers in my scroll view ( something like in a quest log example ) and only on four of them this error occurs, even tho they look exactly the same ( well they come from a prefab ), so it makes me a little clueless about were to look for the problem.

mikemvpi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #9 on: January 13, 2014, 08:44:11 AM »
Quote
Funny thing is, i have 6 Headers in my scroll view ( something like in a quest log example ) and only on four of them this error occurs, even tho they look exactly the same ( well they come from a prefab )

I think these errors are reported for the items that are initially outside of the clipping range.

matdru

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #10 on: January 13, 2014, 08:47:33 AM »
Ah, sorry of course, that's exactly what's happening! And if i disable the clipping everything is fine, just as you said earlier.

pixeluche

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #11 on: January 20, 2014, 07:27:51 PM »
My scene it`s really simple (with Version: 3.0.8 f7 from scratch) and I have the same issue....

Would anyone know how to fix that?

My scene it`s a scrollview with a grid and many sprites sorted in vertical (yes, some of them are outside of the clipping range)....and that`s all.... it works  fine when I play, but console says:


Quote
   
Invalid parameter because it was infinity or nan.
UnityEngine.BoxCllider: set_center(Vector3)

dest.radius>=0.0f
UnityEngine.BoxCollider:set_center(Vector3)
 


thanks....!



« Last Edit: January 20, 2014, 07:36:50 PM by pixeluche »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview items errors when located outside clipping range
« Reply #12 on: January 21, 2014, 01:13:07 AM »
I don't remember if I fixed it in 3.0.9 f2, but it will certainly be fixed in f3.