Search Unity

OnPostprocessGameObjectWithUserProperties no children exist

Discussion in 'Scripting' started by GabeF, Jan 1, 2014.

  1. GabeF

    GabeF

    Joined:
    Sep 28, 2012
    Posts:
    38
    Hey Everyone,

    I have a slight problem. I create a collision class. I'm using this script which should work, and seems to when I put it in the start() method

    Code (csharp):
    1.  
    2. foreach (Transform child in transform)
    3. {
    4. Debug.Log("Assigning mesh collider");
    5. }
    6.  
    But what I'm doing is to execute this method before the start of the game. on setup, so I created a separate class in the Editor folder called Autorun, which runs as soon as my model is imported. I have one custom property in the model that's used as a string.
    Code (csharp):
    1.  
    2. public void OnPostprocessGameObjectWithUserProperties (GameObject g, string[] propNames, System.Object[] values)
    3. {
    4. Debug.Log(g.transform.childCount);
    5. }
    6.  
    This seems to return 0 children.
    But when I put it in the start() method of the collision class, it returns 1 child.

    Is this something to do with the children not being initialized before the game starts? How do I overcome this?

    Much obliged