Object Picker does not see prefabs with a specific type.

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.

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.

This is still not fixed in 2017.4.22 LTS

There is a false positive fix :

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.

Still broken in 2019.3b4. It would be nice if someone from Unity could fix this 5 year old bug…

Can confirm for 2019.3.4f1

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

I reached out to Unity, and they confirmed that Unity Issue Tracker - Object picker does not find a prefab with the required component if the prefab 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.

1 Like

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.

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.

3 Likes

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.

1 Like

Since it doesn’t seem this will ever be fixed/changed as per Unity Issue Tracker - Object picker does not find a prefab with the required component if the prefab is in the Assets folder (not in Hierarchy)
I think the best workaround for now is to use AssetDatabase.FindAssets to find all prefabs of the desired type, and maybe show them as a drop-down, or however you want.

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.

1 Like

This topic makes me nostalgic :roll_eyes:. We can almost celebrate its 10th birthday!

2 Likes

At least we have “production ready” DOTS now. :smile:

Anyway, this feature has actually been secretly available a while by changing to the “Advanced Object Selector” in Preferences → Search.
Not sure when they added it, because they don’t like to show “unimportant” stuff like that in the docs, but it’s found in 2021.3 but not 2020.3.

4 Likes

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.

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.

[SearchContext("p: t:YourComponent", "asset", SearchViewFlags.GridView)]
public YourComponent prefab;
2 Likes

Object Selector > Advanced is great!

It’s what we’ve been waiting for!

BUT!!

When double-clicking the desired objects from the Advanced Search, Unity will set the field.
However, it will then change the selection to the picked object. :rage:

This is default behaviour for the CMD+K search, obviously: double click = select object.
But it should not be the default behaviour for Object Selector search.

This defeats the entire purpose, breaks the whole workflow, you have to go back and search for the object you were working on.

Guess I’ll submit another bug.

[Edit:] IN-72614

2 Likes

Thanks for the feedback @noio ,

we will address this shortly. We are trying to improve a lot of the Searech/Picker workflow both in terms of usability and performance.

Will Goldstone, a great designer at Unity, is gathering feedback on the Advance picker experience. Feel free to add your feedback to this thread: