Hello there,
I am facing a very strange bug. I wrote a python script to give every asset a prefix in the project. I tested the script in the unreal third person template. Everything runs smoothly after the renaming in the Editor.
Then I restarted the project and now things go wild, it seams unreal try to search for old references and breaks because they are not there anymore. It looses connection for animBP, materials etc. everything I renamed.
But just after the restart of the Editor, and I wonder how this can happen? Is there anything I am missing to save or rereference?
This is the core of the renaming script with a custom GetProperPrefix function elsewhere in the script in case you are wondering. The Script and unreal is working fine till I reopen the project. I highly appreciate any hints what I am missing. Thank you
editorAssetLib = MyEditorAssetLibrary()
allAssets = editorAssetLib.list_assets(workingPath, True, False)
allAssetsCount = len(allAssets)
selectedAssetPath = workingPath
with unreal.ScopedSlowTask(allAssetsCount, selectedAssetPath) as ST:
ST.make_dialog(True)
for asset in allAssets:
_assetData = editorAssetLib.find_asset_data(asset)
_assetName = _assetData.get_asset().get_name()
_assetPathName = _assetData.get_asset().get_path_name()
_assetPathOnly = _assetPathName.replace((_assetName + "." + _assetName), "")
_assetClassName = _assetData.get_asset().get_class().get_name()
_assetPrefix = GetProperPrefix(_assetClassName)
if _assetName.startswith(_assetPrefix):
continue
elif _assetPrefix == "":
continue
else:
_targetPathName = _assetPathOnly + ("%s%s%s%s%s%s%s" % (_assetPrefix, "_", _assetName, ".", _assetPrefix, "_", _assetName))
editorAssetLib.rename_asset(_assetPathName, _targetPathName)
unreal.log(">>>>>> Renaming [%s] to [%s]" %(_assetPathName, _targetPathName))
if ST.should_cancel():
break
ST.enter_progress_frame(1, asset)