Hi all,
Right now I’m trying to make a tool that allows me to edit a specific pawn class. I’ve made it only show the components I want to edit, a preview of the pawn, and certain properties on the currently selected component. Its basically setup like the BP editor, except its way less stuff and built using the new UEditorUtilityWidget class.
So I’m wondering now how I can save the changes made to the pawn instance of the asset into the blueprint that I’m editing. This is what my current save function looks like:
void UMyVehicleEditorUtility::SaveAsset()
{
TArray<UPackage*> PackagesToSave;
if (SelectedBlueprint != nullptr && SelectedBlueprint->IsAsset())
{
SelectedBlueprint->Modify();
PackagesToSave.Add(SelectedBlueprint->GetOutermost());
}
FEditorFileUtils::PromptForCheckoutAndSave(PackagesToSave, bCheckDirtyOnAssetSave,
/*bPromptToSave=*/ false);
}
The “SelectedBlueprint” is a UBlueprint* and in the editor i’m editing an AActor*, which is spawned with this info:
FActorSpawnParameters SpawnInfo;
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
SpawnInfo.bNoFail = true;
SpawnInfo.ObjectFlags = RF_Transient | RF_Transactional;
Right now i’m just directly changing the values on the instance, so the actual UBlueprint doesn’t change. I think I need to mark the component I’m working on as “dirty” so it can mark its package as dirty, but I’ve been calling UObject::Modify() on those components and that didn’t seem to do anything.
I’ve also gone down the rabbit hole of using SKismetInspector to just create the regular details panel, but since my tool doesn’t derive from the FBlueprintEditor I don’t believe that I can use it properly. It did show up when I used it, but when I edited a property on a component, the details panel collapsed (or just went away) and when I tried saving the changes it didn’t stick.
TLDR:
How can I modify an instance of an object, during editor time, and save those changes to the blueprint (or asset)?
sorry if this wasn’t clear, but the whole saving system in UE4 seems really complicated so its hard for me to rap my head around. Thanks for reading, any help is appreciated!