Search Unity

Search for an Object in Game

Discussion in 'Editor & General Support' started by ansiaries, Jan 8, 2015.

  1. ansiaries

    ansiaries

    Joined:
    Jul 22, 2014
    Posts:
    22
    can i make a search in Unity scene/game ?

    for example

    i have 3 balls, red, yellow and green
    when i am playing the game i do not know where the green ball is
    so i make a search to find the green ball and unity make the green ball highlighted or zoom to that object
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    If you Mean inside the Scene View, you can use the search field of the hierarchy window and press F to focus and zoom in if you selected the targeted GamObject.
    If you what the functionality inside the game view, you have to code it yourself.
     
  3. ansiaries

    ansiaries

    Joined:
    Jul 22, 2014
    Posts:
    22
    Thanks
    yes i mean inside game.
    Could it be done in both JS and C# ?
     
  4. PolymorphiK Games

    PolymorphiK Games

    Joined:
    Oct 5, 2014
    Posts:
    51
    Yes, you can either tag them accordingly or if they have a unique component use that. For example.


    Code (CSharp):
    1. GameObject target = GameObject.FindGameObjectsWithTag("Tag");
    or

    Code (CSharp):
    1. Object.FindObjectOfType(typeof(Component)) as Component
    Where Component is the unique component of that game object.
     
    ansiaries likes this.