Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Object Picker does not see prefabs with a specific type.

Discussion in 'Editor & General Support' started by stefan3iii, Jan 13, 2014.

  1. stefan3iii

    stefan3iii

    Joined:
    Oct 15, 2013
    Posts:
    1
    I have a script called Enemy, and variable declared in another script (Spawner):
    class Spawner
    {
    public Enemy EnemyType;
    }

    In my scene I have a GameObject with a Spawner component. I see the EnemyType variable there, but when I open the Object Picker it will only show Enemy objects that are in the scene, it will not show any Enemy prefab objects in the 'Assets' tab. If I drag an Enemy prefab to the field it correctly assigns it, and when I run the game everything works as expected. This makes me think this is a UI bug with the Object Picker? If I can assign the prefab by drag/drop, then I should be able to do the same with the Object Picker.

    Also note that if I make the EnemyType variable a GameObject type instead, the Object Picker will show all prefab assets as you'd expect, so that appears to work.
     
  2. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    226
    I noticed the same thing for ScriptableObject assets.

    If I have a ScriptableObject reference in the inspector, the Object Picker doesn't seem to find the assets in my project.
     
  3. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    505
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,296
    I can confirm it does not work for me in 2019.2.0f1. Object picker don't see any prefabs, but there are valid objects with components.
     
  5. Ziflin

    Ziflin

    Joined:
    Mar 12, 2013
    Posts:
    132
    Still broken in 2019.3b4. It would be nice if someone from Unity could fix this 5 year old bug..
     
  6. Telgemannen

    Telgemannen

    Joined:
    Jun 10, 2015
    Posts:
    12
    Can confirm for 2019.3.4f1
     
  7. Deleted User

    Deleted User

    Guest

    My guess is that it's not broken but has never been implemented for any other use case than GameObject
     
  8. SolidAlloy

    SolidAlloy

    Joined:
    Oct 21, 2019
    Posts:
    58
    I reached out to Unity, and they confirmed that https://issuetracker.unity3d.com/is...efab-is-in-the-assets-folder-not-in-hierarchy was marked as Fixed by mistake. They have now changed the status to By Design with the following note:
    The Object Picker will only show Assets that have the same type as requested, it will not show the elements that contain the requested type. We do this because of performance reasons, otherwise, we would have to load all the assets to memory and search for all elements in a disk, this can be quite a slow operation.
     
  9. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    943
    Just a tip for missing scriptableobjects in the picker, sometimes it helps to rightclick-reimport them. I guess this forces a re-registration in the assetdatabase, which seems to get confused if scripts are renamed or something else i'm not sure of changes with them.
     
  10. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,296
    I understand why it is "by design", but to be honest this feature would be large speed up, drag and dropping each element manually is really not efficient.

    Furthermore this issue was made before new prefab workflow if I am correct. It was reported in 2017 while today is 2021, is it really not possible to make it work nowdays? Also can't they just load prefabs like it happens when GameObject type is used and filter them by required component? Only parent (prefab) object must be checked.
    Even if that would be too slow, then maybe it would be possible to limit numer of filtered prefabs.
     
    hnngaf, Silly_Rollo and SolidAlloy like this.
  11. goofghost

    goofghost

    Joined:
    Jul 3, 2019
    Posts:
    1
    Its not just prefabs that don't show up for me, its a LOT of things. The Asset selector button is almost totally useless to me except for Sprites and Audio Clips. Is this really a design choice?

    If so, what about cases where you cannot apparently drag and drop things from your project folder to the object field?

    For example: in the layer tab for an Animator that I'm working with, I'm trying to select an Avatar Mask for a certain layer - but the mini-window containing the object field that would be the target for a 'drag and drop' disappears when you click anywhere away from the Animator window, so when I try to drag and drop an Avatar Mask from the project folder to the field, it goes bye-bye. And Avatar Masks are one of many 'types' that don't show up.
     
    noio likes this.
  12. aklgupta

    aklgupta

    Joined:
    Jun 9, 2014
    Posts:
    29
  13. VirZOOM

    VirZOOM

    Joined:
    Mar 16, 2017
    Posts:
    5
    We're hitting this now with ScriptableObjects and hope Unity will consider caching prefab object types somewhere. That would enable the Object Picker filter them efficiently, and as expected like drag-and-drop does. That seems feasible given all the other things the Unity editor tracks. It's not like prefab object types change every frame.
     
    noio likes this.
  14. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    226
    This topic makes me nostalgic :rolleyes:. We can almost celebrate its 10th birthday!
     
    Kurt-Dekker and Hexrin like this.
  15. freso

    freso

    Joined:
    Mar 19, 2013
    Posts:
    73
  16. Crystalline

    Crystalline

    Joined:
    Sep 11, 2013
    Posts:
    168
    Its 2024, and even with the latest version, unity wont show ANY object when trying to select them . It just brings up the assets/scene window and is completely empty.
    Always the worse priorities for this company and the core stuff struggles.
     
    Last edited: Feb 23, 2024
  17. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,296
    Literally one post above yours the guy provided solution, but you still whine about the same feature.
    Simply add this attribute to your field and you get search window with prefabs only with the component you want.
    Code (CSharp):
    1. [SearchContext("p: t:YourComponent", "asset", SearchViewFlags.GridView)]
    2. public YourComponent prefab;
     
    noio and spiney199 like this.