Author Topic: UICenterOnChild not Working  (Read 3095 times)

dyego_s

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
UICenterOnChild not Working
« 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?
« Last Edit: August 10, 2014, 12:31:18 PM by dyego_s »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICenterOnChild not Working
« Reply #1 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?

hrlarsen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 35
    • View Profile
Re: UICenterOnChild not Working
« Reply #2 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

dyego_s

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UICenterOnChild not Working
« Reply #3 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICenterOnChild not Working
« Reply #4 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(); } }
« Last Edit: August 12, 2014, 03:48:01 AM by ArenMook »