Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: dyego_s on August 10, 2014, 11:54:46 AM

Title: UICenterOnChild not Working
Post by: dyego_s on August 10, 2014, 11:54:46 AM
In the new version o NGUI 3.6.9 UIcenterOnChild is not working properly.

I activate the scrollview collider by code. So in the old version if I just put UIcenterOnChild on the scrollview and activate it later it was working fine. now it's not working in the same way. Now I need to activate UIcenterOnChild after I enable scrollview to work. But sometimes it does not work.

is it a bug?
Title: Re: UICenterOnChild not Working
Post by: ArenMook on August 10, 2014, 05:57:55 PM
When UICenterOnChild gets activated, it sets the scroll view's "centerOnChild" reference to itself, so that the scroll view knows that this component is present. This is new in 3.6.9. Everything else should be pretty much the same. How can I reproduce the issue on my end?
Title: Re: UICenterOnChild not Working
Post by: hrlarsen on August 11, 2014, 03:07:13 AM
It seems that it does not receive the OnDragFinished event. I have a simple setup

- ScrollView
-- UIGrid with UICenterOnChild
--- Widget with Collider and DragScrollView (hereunder a label and a texture)

Hope this helps you to identify the issue
Title: Re: UICenterOnChild not Working
Post by: dyego_s on August 11, 2014, 08:06:18 AM
When UICenterOnChild gets activated, it sets the scroll view's "centerOnChild" reference to itself, so that the scroll view knows that this component is present. This is new in 3.6.9. Everything else should be pretty much the same. How can I reproduce the issue on my end?

To reproduce this issue you have to create a normal scrollview. In my case a don't need UIGrid. So put the centerOnChild in the scrollview gameobject. put some sprites inside the scrollview and press play. You will notice that the centerOnChild won't work.
Title: Re: UICenterOnChild not Working
Post by: ArenMook on August 12, 2014, 03:40:33 AM
Thanks, I reproduced it -- it will be fixed in the Pro repository shortly, and will be live on the Asset Store this Friday. You can also fix it locally by adding a Start() function and changing OnEnable():
  1.         void Start () { Recenter(); if (mScrollView) mScrollView.centerOnChild = this; }
  2.         void OnEnable () { if (mScrollView) { mScrollView.centerOnChild = this; Recenter(); } }