HI, I am writing my own Ufactory for a specifiic filetype to create a DataAsset from reading the dragged in file.
UP2CDnDFactory::UP2CDnDFactory( const FObjectInitializer& ObjectInitializer )
: Super(ObjectInitializer)
{
Formats.Add(FString(TEXT("p2c;")) + NSLOCTEXT("UTextAssetFactory", "FormatTxt", "Text File").ToString());
SupportedClass = UChamberDataAsset::StaticClass();
bCreateNew = false;
bEditorImport = true;
OverwriteYesOrNoToAllState = -1;
}
UObject* UP2CDnDFactory::FactoryCreateFile(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags,
const FString& Filename, const TCHAR* Parms, FFeedbackContext* Warn, bool& bOutOperationCanceled)
{
UChamberDataAsset* chamberDataAsset = nullptr;
FString TextString;
if (FFileHelper::LoadFileToString(TextString, *Filename))
{
chamberDataAsset = NewObject<UChamberDataAsset>(InParent, InClass, InName, Flags);
}
//parsing and filling the DataAsset
Parser p = Parser();
p.Parse(*chamberDataAsset, std::string(TCHAR_TO_UTF8(*Filename)));
bOutOperationCanceled = false;
return chamberDataAsset;
}
However this only works if the file is a new file. When I am trying to reimport a p2c file I get the error that the import failed without any logs beeing printed.
Any idea how I can ask the user if he wants to overwrite the existing DataAsset?
Thanks in advance!