We are currently trying to refine our Asset Pipeline system, where we validate our assets in our project by ensuring all of them have proper asset naming by type. We already have a solution that is semi working, but we encountered an issue which causes Unreal to crash.
Example:
We have an Skeletal Mesh named Bunny, but for our naming standards it should be SK_Bunny, so our system automatically flags it and renames it when the PackageSavedWithContextEvent is triggered.
Most of the time it works, but sometimes it crashes the whole engine, most probably because our implementation also calls
UEditorLoadingAndSavingUtils::SavePackages, so we trigger the same process again from within.
I also tried to use OnAssetRenamed delegate to trigger the functionality, but it keeps the original and the new object as well visible in the ContentBrowser even though the old asset is null.
So, my question what is the proper way to ensure that the Asset (either imported, created or renamed) has a correct name and it is automatically triggered?
Those call point unfortunately aren’t made with the assumption that the data might change during the broadcast. If you are to react to those consider deferring the rename to the next tick. Also make sure to use the function in the IAssetTools to rename the assets.
We generally prefer a validation base approach where a combo of presummit validator and post submit build health automation will check for those type of issues. Look for use of UEditorValidatorBase.
Otherwise, most asset imports use interchange (Our new asset import framework). With interchange you can add a pipeline step to customize the import. That step would just take the factory node for the new assets and just add your prefix to the name of the assets. For the other imports, the UImportSubsystem as some broadcast there.
Thank you very much for your quick answer! I managed to solve the problem by correcting the name using the Tick() method. I know it is not ideal, but this was the easiest solution right now.
However we will consider to refactor our method using the suggested UEditorValidatorBase system.