Author Topic: NullPointer using ScrollView  (Read 1594 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
NullPointer using ScrollView
« on: December 17, 2013, 05:41:54 AM »
I have a scrollview with a vertical scrollbar.
The GameObject holding everything is disabled in the scene, and in the code, when I'm calling "m_scrollView.ResetPosition()" I have a null pointer.

Here's the stacktrace :
Quote
NullReferenceException
UnityEngine.Component.get_gameObject ()
UnityEngine.Component.GetComponentsInChildren[UIWidget] (Boolean includeInactive)
NGUIMath.CalculateRelativeWidgetBounds (UnityEngine.Transform root, UnityEngine.Transform child, Boolean considerInactive) (at Assets/NGUI/Scripts/Internal/NGUIMath.cs:376)
NGUIMath.CalculateRelativeWidgetBounds (UnityEngine.Transform root, UnityEngine.Transform child) (at Assets/NGUI/Scripts/Internal/NGUIMath.cs:367)
UIScrollView.get_bounds () (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:161)
UIScrollView.SetDragAmount (Single x, Single y, Boolean updateScrollbars) (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:463)
UIScrollView.ResetPosition () (at Assets/NGUI/Scripts/Interaction/UIScrollView.cs:527)
here is the call to ResetPosition

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NullPointer using ScrollView
« Reply #1 on: December 17, 2013, 10:14:08 AM »
I can add a GetActive check in ResetPosition, but you shouldn't be calling it on a disabled object to begin with.