Warning> Accepting ObjectPaths is deprecated behavior and will be removed in a future release;

Another question for any Python wizards
Following this Editor scripting workshop

but have 2 questions.

1 My simple functions take a LONG time to execute, up to 30 seconds sometimes on a farirly simple project (Northwood demo). In the walkthru they execute almost immediately.

2 Encountering several warnings containing

…Accepting ObjectPaths is deprecated behavior and will be removed in a future release; TryConvertFilenameToLongPackageName will fail on ObjectPaths.

This is with the following simple method >

def getAssetClass():
EAL = unreal.EditorAssetLibrary
assetPaths = EAL.list_assets(‘/Game’)
for assetPath in assetPaths:
assetData = EAL.find_asset_data(assetPath)
assetClass = assetData.asset_class
print(assetClass)

Why?

3 Likes

What version of Engine are you using? There are a couple changes from 5.0 to 5.1 that make parts of the 5.0 tutorial outdated. One change is that EAL.find_asset_data() takes a slightly modified asset path than returned by list_assets(). You need to remove the last part of the path after the period.

One solution is to add this line as the first line in the for loop

asset_path = asset_path.split('.')[0]

Another difference is the AssetData structure/class itself. See the differences here:
https://docs.unrealengine.com/5.0/en-US/PythonAPI/class/AssetData.html#unreal.AssetData
https://docs.unrealengine.com/5.1/en-US/PythonAPI/class/AssetData.html#unreal.AssetData

With 5.1, the property asset_class has been deprecated. It can now be found within the new property asset_class_path. You need to edit the assignment of the variable assetClass.

asset_class = asset_data.asset_class_path.asset_name
2 Likes

Thanks it works!
But I´m also having the problem of taking a long time to execute.
Do you guys know why?
Thank you so much for the help!

I’m seeing this error in a BP only project. What BP node would I be using that would cause this warning?

It appears to be the “GetClass” node that is throwing the warning. I’m not sure if there’s a way to get around that currently in BP. I attempted to use GetPrimaryAssetIDFromObject, and then GetClassFromPrimaryAssetID but that didn’t appear to work, got access nones coming out of those class pins.

I have the same problem. Have you found a solution?

Script execution is very slow in UE5.3, it takes about 3 minutes to print all the actors in the scene, during which you can’t do anything with the UE editor. I even thought UE editor was unresponsive.

I used UE5.2 for comparison and found that it reduced the execution time to 20 seconds, but it still wasn’t as responsive as the tutorial.

My computer configuration is 12900K+RTX6000 ADA, which should not affect the running speed.

def getAssetClass():
EAL = unreal.EditorAssetLibrary
assetPaths = EAL.list_assets(‘/Game/autoCreated’)

for assetPath in assetPaths:
    assetData = EAL.find_asset_data(assetPath)
    assetclass = assetData.asset_class_path.asset_name

    print(assetclass)
总结

此文本将被隐藏

Fixed code up until 5:20 in the video:


def getAssetClass():

    EAL = unreal.EditorAssetLibrary()
    
    assetPaths = EAL.list_assets('/Game')
    
    for assetPath in assetPaths:
        assetData = EAL.find_asset_data(assetPath)
        assetClass = assetData.asset_class_path.asset_name
        print (assetClass)

apparently the warnings of

LogPackageName: Warning: TryConvertFilenameToLongPackageName was passed an ObjectPath … Accepting ObjectPaths is deprecated behavior and will be removed in a future release

is harmless and nothing in the 5.3 python documentation discusses alternatives.