-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot favorite prefabs #36
Comments
Interesting, I have to take a look, I must admit I can add prefabs without problems to the favorites but I believe I am adding them through the history window icon and not by drag and drop to the favorites window. Will check it later but if you have some alternative and want to make a pull request, I can check and test that and if it works merge it. Thanks for reporting the issue |
Which version of unity, os, etc, are you on? |
So I found how to cause the "miracle", which is what you are doing in the GIF: you must have a non-game object asset selected, then directly drag and drop the prefab, without selecting it first. This will exploit a bug in You can even do this with right-click > Favorite Item but it's trickier: right-click auto-selects the target. So you need to select a non-prefab asset first, then Ctrl+Right Click to additionally select the prefab you want to favorite and also open the contextual menu, then Favorite Item. Selection.activeObject only checks the first selection, so this will also check the non-prefab, which has no scene and can be added as favorite. You must then remove the non-prefab asset you selected from the favorites... But that's all exploits that explain why it inconsistently worked. This should of course be fixed by replacing P.S.: I'm using Unity 2022.1.10f1 on Ubuntu, but I suspect that with my new explanations, it is not relevant anymore. |
Awesome finding, will take a look, thanks for all the info. |
@hsandt I changed to check if object is an asset now, and tested with different cases, can't be sure if it is a complete fix, don't have a lot of time to spend testing it, take a look if it works and will upload a new version later today. |
Changed to check reference object parameter instead of always Selection.object and also changed to check if object is an asset instead of scene == null, and should work since favorites window can only favorite assets.
I tested v1.1.8, and it's working fine! |
I cannot add prefabs to favorites. Both the Favorite Item menu item and drag-and-drop to Favorites stop working. Nothing happens when I do them. I removed some entries in case I was reaching some max limit, but it didn't help.
Debugging code FavoriteElements > CanBeFavorite shows that when dealing with a game object, the test
go.scene == null
always fails, because scene is a struct (although debug prints scene as "null (null)").To be exact, I miraculously managed to add a prefab to the favorites, but at that moment I wasn't debugging CanBeFavorite, so I have no idea how I managed to do it (maybe the first time you drag-and-drop, scene is really considered null by the engine for some reason, although I don't see how it's possible from C#'s PoV; or maybe the check was exceptionally skipped for some reason).
The check should probably be replaced with another way to detect invalid scenes, e.g.
!go.scene.IsValid()
, or alternatively directly check if the game object is an asset withAssetDatabase.Contains(go)
.The text was updated successfully, but these errors were encountered: