Author Topic: CenterOnChild returns inactive gameobject  (Read 3492 times)

HDFrisk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
CenterOnChild returns inactive gameobject
« on: April 04, 2014, 09:03:43 AM »
Hi.
I've searched the forum but could not find any fix to my problem, so here it is.

I have a UIGrid with UICenterOnChild script and 4 childed game objects in my grid(lets call them page1, page2, page3 and page4).
If I get the current centered child(activeCenterChild.centeredObject), having all 4 children in my grid active, it returns the right one.
But if I toggle 2 of them off, say for example page1 and page2, leaving only page3 and page4 active, when I center on page3, which is now my first object, activeCenterChild.centeredObject returns page1, even though I have checked the hide inactive checkbox. Is there a cache that needs to be cleared?

I have made a temporary fix, by moving the objects I want to toggle off to another parent, so UIGrid don't have them as children any more. Is the hideInactive really working?

/HDFrisk

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: CenterOnChild returns inactive gameobject
« Reply #1 on: April 04, 2014, 10:26:47 PM »
UICenterOnChild has a Recenter() function that you should call whenever you modify the content.

HDFrisk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: CenterOnChild returns inactive gameobject
« Reply #2 on: April 05, 2014, 09:22:08 AM »
Hi, thanks for fast reply.
That gives med the correct gameobject indeed, but it results in a non correct pivot point for my grid, resulting in a scrollview able to scroll 4 pages and not only the 2 active pages. I tried rebuilding panels, repositioning the grid.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: CenterOnChild returns inactive gameobject
« Reply #3 on: April 05, 2014, 11:52:25 AM »
There is no logic in UICenterOnChild that would "ignore" certain children. If you need that logic you will need to add it yourself.