Author Topic: 3.4.9 ScrollView Issues  (Read 1765 times)

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
3.4.9 ScrollView Issues
« on: February 13, 2014, 01:50:36 PM »
I dynamically populate a ScrollView at one point, and I noticed 2 oddities.

1) ResetPosition doesn't work if the object is disabled in the hierarchy. This is a problem for me since when I go to a new screen, I populate the ScrollView before I enabled the screen. I can work around this, but it'd be much more convenient to be able to reset scrolling position while the object is disabled.

2) In an attempt to work around 1) I noticed several methods throw exceptions if the ScrollView has never been enabled. For example, MoveAbsolute throws an exception because mTrans is null. MoveRelative throw one because panel is null.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3.4.9 ScrollView Issues
« Reply #1 on: February 14, 2014, 05:39:16 AM »
Yeeeah... you should not work with something that has not even been started yet. The initialization happens in Awake(), which is the first thing executed as soon as the component has a chance to start up. Awake() is executed first -- before OnEnable() (and regardless of whether the component is enabled or not). In your case I am guessing the game object is disabled outright... so I strongly advise you to first enable it before working with its components.