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 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.
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.
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.
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.
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.
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;
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.
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.