playMaker

Author Topic: Get Child Number?  (Read 1793 times)

jess84

  • Hero Member
  • *****
  • Posts: 515
Get Child Number?
« on: May 27, 2014, 08:40:18 AM »
Hi,

On each of my child objects, I want to be able to find out what number that child is of its parent and store it as an Int.

E.g. I have

/Buttons
    Button_001   (I want to know this is child 01)
    Button_002   (I want to know this is child 02)

etc.

None of the Child actions seem to be able to do this?

(I can't just use Get Name, as I have tutorial levels interspersed among the main levels, so the end of the button naming isn't consisten)


redikann

  • Full Member
  • ***
  • Posts: 174
Re: Get Child Number?
« Reply #1 on: May 27, 2014, 10:37:32 PM »
Well you can make it line up how you want by naming your children something like
0_Button
1_Button
as children start at 0 and go thru the list if you name your children with a preceding number they will have no choice but to fall in line.
get Child Num action seems to be what you want.
« Last Edit: May 27, 2014, 10:42:25 PM by redikann »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Get Child Number?
« Reply #2 on: May 28, 2014, 07:28:26 AM »
When you place objects in the hierarchy Unity organizes that kind of data different. I'm not really sure how the technical stuff works but basically if you have 8 boxes as children they're organized on the backend by age (essentially), so it would sort them by age spent as children of that parent in this action while you see them listed by name in the hierarchy. However if you take them out of the parented hierarchy after you name them correctly, then put them back in it will reorganize them and they'll line up right until you mess with the naming again.

Weird behavior, but maybe they patched it in the 1000 something bugs they fixes in 4.5.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D