Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Object Picker show objects with custom components

Discussion in 'Editor & General Support' started by Wattosan, Feb 27, 2018.

  1. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    450
    Hello,

    I am currently writing an editor script, and I am using the EditorGUIUtility.ShowObjectPicker<T>() function to display the object picker on a button press.

    However, I would like to only show objects, which have certain components attached to them. Currently, I can set the generic type to "GameObject". This however displays all the prefabs. I would like it to display prefabs with certain components only. I tried to set the generic type to my custom component. No error was given in the code, however the object picker displays 0 results.

    Is there any way around this, without creating my own object picker?

    Thank you!
    Cheers,
    Frosty
     
  2. daleth90

    daleth90

    Joined:
    Dec 15, 2014
    Posts:
    10
    As far as I know, it's "still" not possible.

    It cannot search with any type of Component. It even cannot search with the built-in components like Animator or Rigidbody.

    However, it works with the type of ScriptableObject and GameObject. As if the object picker never load our prefabs as any component but only GameObject.
     
  3. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    450
    Thank you for the reply!

    I guess I'll have to figure it out on my own.

    Cheers,
    Frosty
     
  4. The_Dogg

    The_Dogg

    Joined:
    Apr 6, 2017
    Posts:
    4
    here is solution
    maybe it help you