20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.75k stars 746 forks source link

how to check if an asset exists or not in particular path? #762

Closed arafat0007 closed 4 years ago

arafat0007 commented 5 years ago

In the official unreal, there are functions like "does_asset_exist". My purpose is to check if a certain asset exists in the particular content browser path or not.

kogen00 commented 5 years ago

Had the same problem, that's what I'm doing, not pretty but it works:

try: mesh = ue.load_object(StaticMesh, assetpath) except: mesh = None if mesh: comp.StaticMesh = mesh

Kind regards, sorry for the non-pythonesk formatting.

Mirko

arafat0007 commented 5 years ago

Thank you @kogen00 i will try it out. Though i had done it other way around. I had to cross check if an image has it's texture available in content or not. If not create one. I manually took file names and compared and checked that.

kogen00 commented 5 years ago

Hi @arafat0007 I think your method is valid. The only difference is, that my (hacky) solution uses the Unreal-Python method asking to load the asset and if not possible (cause the plugin threw an error) assumes that it's not there at this path. I use this way extensively to load a couple of thousand meshes into a blueprint and it has not let me down so far ;)