Dynamically creating assets in-game (without editor)?

Lookup AssetRegistry, it’s in runtime directory so it should be accesable without editor:

https://docs.unrealengine.com/latest/INT/API/Runtime/AssetRegistry/FAssetRegistryModule/index.html

Here you have soe example how to use it from engine source code:

https://github.com/EpicGames/UnrealEngine/blob/dff3c48be101bb9f84633a733ef79c91c38d9542/Engine/Source/Editor/DetailCustomizations/Private/CurveColorCustomization.cpp#L310
https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Editor/Cascade/Private/Tests/ParticleSystemTests.cpp

I not sure if it let you save without editor, you need to check it out yourself

Note if you don’t plan to save those assets… you don’t need assets at all, asset is a system that stores UObject like resource, but they still UObject and you can create them in memoery as any other UObject without touching asset system.

Hi. I am currently putting a lot of work into a procedural character mesh generation system that dynamically creates new SkeletalMeshes and other assets at runtime.

After learning UE4 for some time now, it has become clear that not everything you can do while testing with editor and PIE is going to work in the final stand-alone game. So, what about asset creation, modification and deletion from code? Is that something that I can do at a final game’s runtime? Or is the whole “content” folder to be seen as a static collection of assets once out of the editor?

This is very important for me to know, because I would have to take a whole different approach for my work if this is editor-only functionality.

Most of my game data is organized in DataAsset-derived classes, so I can create and edit objects (like item type descriptors for example) in the editor. That seemed to be the logical choice for me.

So, the big question is: can I save assets at game’s runtime :confused:

So far, I haven’t even managed to save them from code. I called UPackage::Save(…) and it looked like it did, but when I restarted the editor, the assets were gone. Not sure why. But the fact that a progress bar popped up on saving, just as if you press “save” manually, makes me doubt this is going to work.

So, I managed to save an asset via code and have it reload on next startup.

How can I test this in-game now? PIE will probably not give me any answers. What about starting “Standalone” from the editor? Would that make a difference or would editor-only functionality still be enabled?

May I know how you did? By using UPackage::SavePackage, my assets are not saved to disk :confused:

If you want to manipulate and save data assets at game’s runtime, I don’t think it’s possible.

If you just want to save data assets in the editor after generating or changing them by code, I recommend just raising the “dirty”-flag on them instead, so they can easily be saved manually afterwards. (…->GetOutermost()->SetDirtyFlag(true))