How can I save some existing UObject to .uasset file from code? I want to do: Instantiate an object of UMyClass, fill it with data and then save it as .uasset.
Is something like this or similar possible?
Thank You for any help.
PS. The reason I want to do this is that i want to be able to create files in editor (from code) and make sure those files are then included in packaged game. Currently, the only files being packaged are .uassets (without modifying settings, but that’s something I don’t want to do since it’s a plugin)
Yes. You need to make sure that you construct your object with RF_StandAlone. Then you can save it using SavePackage(). There are plenty of examples inside the editor on how to do this.
I had to also reload the package generated this way (either by restarting the editor, or by calling ReloadPackage in PackageReload.h) in order to be able to edit the asset, as otherwise the editor would have complained about it being only partially loaded.