Skip to content

Commit

Permalink
Added support for drag & drop of text files.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpreussner committed Dec 14, 2015
1 parent 2f20c7b commit 492023e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Source/TextAssetEditor/Private/Factories/TextAssetFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
UTextAssetFactory::UTextAssetFactory( const FObjectInitializer& ObjectInitializer )
: Super(ObjectInitializer)
{
Formats.Add(FString(TEXT("txt;")) + NSLOCTEXT("UTextAssetFactory", "FormatTxt", "Text File").ToString());
SupportedClass = UTextAsset::StaticClass();
bCreateNew = false;
bEditorImport = true;
Expand All @@ -21,5 +22,16 @@ UTextAssetFactory::UTextAssetFactory( const FObjectInitializer& ObjectInitialize

UObject* UTextAssetFactory::FactoryCreateBinary(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, const TCHAR* Type, const uint8*& Buffer, const uint8* BufferEnd, FFeedbackContext* Warn)
{
return NewObject<UTextAsset>(InParent, Class, Name, Flags);
UTextAsset* TextAsset = nullptr;
FString TextString;

FEditorDelegates::OnAssetPreImport.Broadcast(this, Class, InParent, Name, Type);

if (FFileHelper::LoadFileToString(TextString, *CurrentFilename))
{
TextAsset = NewObject<UTextAsset>(InParent, Class, Name, Flags);
TextAsset->Text = FText::FromString(TextString);
}

return TextAsset;
}

0 comments on commit 492023e

Please sign in to comment.