Search Unity

(Solved) Bug: script finds no children on GameObject on game startup (tick 0)

Discussion in 'Editor & General Support' started by artyom-v, Mar 24, 2017.

  1. artyom-v

    artyom-v

    Joined:
    Jan 22, 2015
    Posts:
    1
    We have a game object named TrophyManager in the scene. This game object is DontDestroyOnLoad. In Awake this script searches for Trophy scripts in it's children. There are 16 Trophy GameObjects in TrophyManager. And since some latest Unity version (5.5.1 or 5.5.2) sometimes it started to happen (~20% of Unity launches) that TrophyManager finds 0 Trophy objects in its Awake. If we repeat search for Trophy objects in next tick after Awake - they are found. On iOS bug reproduced more often.
    Here is a screenshot of what the hierarchy looks like:


    The solution is the following:
    TrophyManager object was linked to TrophyManager prefab that was stored on a disk. And there were some changes made in scene TrophyManager during migration to a newer Unity version. When we applied the TrophyManager changes in prefab - bug disappeared. Changes were actually made in child Trophy game objects.

    A screenshot of changes made after prefab applying: