Search Unity

Search System in Unity

Discussion in 'Scripting' started by ShiroCruck, Feb 25, 2020.

  1. ShiroCruck

    ShiroCruck

    Joined:
    Feb 25, 2020
    Posts:
    9
    Hi everyone!!!

    I want to do a system where you can search by name and shows you the prefabs with that name.

    Can anyone help me?
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    Hi and welcome.
    If it has to be by name (ie you want to create a UI where you type something in and search for that prefab), then you can use Ressources.Load. Something similar is discussed here: https://answers.unity.com/questions/674127/how-to-find-a-prefab-via-script.html

    If it doesnt have to be a UI where you type in the name, you could also just create a List<GameObject> where you put (either manually or automatically by looking through ressources) all your Prefabs.
    When you have the GameObjects you can Instantiate them by using Instantiate(). If i understood you correctly, what you want is to preview these Prefabs, so you probably want to create some UI or effect where you show the instantiated object (enabling / disabling the correct one/s), potentially allowing the user to rotate it and so on.

    Hope this helps!
     
  3. ShiroCruck

    ShiroCruck

    Joined:
    Feb 25, 2020
    Posts:
    9
    Thanks, I will try to do it!! :)