Search Unity

GameObject.Find Efficiency

Discussion in 'Scripting' started by researchDolphin, Dec 2, 2010.

  1. researchDolphin

    researchDolphin

    Joined:
    Nov 3, 2010
    Posts:
    11
    :) Hello Forums!

    I am currently trying to find out the efficiency of searching through active objects with GameObject.Find.

    I have seen many saying that it's not efficient. But how exactly does this in-built function works?

    Does this function work by bruteforce iteration (e.g. A-Z) finding or through a more efficient way, perhaps indexing?

    Any helpful soul care to tell me how the GameObject.Find functions as a search algorithm.

    Else, what's in-built in Unity3D that functions as an efficient search algorithm, any suggestion? Thanks!

    Research Dolphin.
     
  2. Chris-Sinclair

    Chris-Sinclair

    Joined:
    Jun 14, 2010
    Posts:
    1,326
    I'd like to believe it's a Dictionary/Hashtable lookup (i.e., O(1) performance), but I honestly couldn't tell you. Why don't you try creating a test scene and find out how many Find() method calls you can invoke per second?