Python 4.20 (Not 20Tab) - how to get selected asset from content browser

Hey guys, I recently posted a question regarding how to get my selected asset via Python. It was posted in the UE4 4.20 preview forum with no response. Considering that seems to be more aimed towards the build and its bugs, it may explain the lack of response. So I’ll try under Development :slight_smile:

I’m looking for a way to (for the test sake’s purposes) print the name of the asset I currently have selected in the asset browser via Python. I fully believe this line of code is definitely in the right direction:

unreal.GlobalEditorUtilityBase.get_selected_assets()

But I get an error mentioning that it needs an argument for “get_selected_assets(ARG)”
It’s looking for an object. But this makes no sense to me… as the object that is selected is the object… Or am I not getting it? Even if I type “unreal.Object” or “object” it tells me that its a type, not an object. I could use some help here.

I recreated the python line with blueprints, and it worked. I’ll attach an image below. That’s great that it works for Blueprints… but I really want to make it work for Python… any helpful ideas?

Thanks again, ahead of time.

assets = unreal.EditorUtilityLibrary.get_selected_assets()

2 Likes