I want to create custom .uasset files from a class that is based on AActor so other people in my team can easily add them to different projects from the editor. Online examples I have seen either use ConstructObject(), which is now deprecated, or NewObject, which I haven’t gotten to work properly yet. I have managed to create a file but if I try to save or edit it then Unreal Engine crashes. From what I can tell the crash is because the world of this new object isn’t set.
FString AssetName = FString(TEXT("MyActor")); FString PathName = FString(TEXT("/Game/CustomAssets/")); FString PackageName = PathName + AssetName; UPackage* Package = CreatePackage(NULL, *PackageName); check(Package); AActor* MyActor = NewObject<AActor>(Package, FName(*AssetName), RF_Public | RF_Standalone); FAssetRegistryModule::AssetCreated(MyActor); MyActor->MarkPackageDirty();