@@ -24,6 +24,41 @@ bool FTextAssetActions::CanFilter()
2424}
2525
2626
27+ void FTextAssetActions::GetActions (const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder)
28+ {
29+ FAssetTypeActions_Base::GetActions (InObjects, MenuBuilder);
30+
31+ auto TextAssets = GetTypedWeakObjectPtrs<UTextAsset>(InObjects);
32+
33+ MenuBuilder.AddMenuEntry (
34+ LOCTEXT (" TextAsset_ReverseText" , " Reverse Text" ),
35+ LOCTEXT (" TextAsset_ReverseTextToolTip" , " Reverse the text stored in the selected text asset(s)." ),
36+ FSlateIcon (),
37+ FUIAction (
38+ FExecuteAction::CreateLambda ([=]{
39+ for (auto & TextAsset : TextAssets)
40+ {
41+ if (TextAsset.IsValid () && !TextAsset->Text .IsEmpty ())
42+ {
43+ TextAsset->Text = FText::FromString (TextAsset->Text .ToString ().Reverse ());
44+ }
45+ }
46+ }),
47+ FCanExecuteAction::CreateLambda ([=] {
48+ for (auto & TextAsset : TextAssets)
49+ {
50+ if (TextAsset.IsValid () && !TextAsset->Text .IsEmpty ())
51+ {
52+ return true ;
53+ }
54+ }
55+ return false ;
56+ })
57+ )
58+ );
59+ }
60+
61+
2762uint32 FTextAssetActions::GetCategories ()
2863{
2964 return EAssetTypeCategories::Misc;
@@ -50,7 +85,7 @@ FColor FTextAssetActions::GetTypeColor() const
5085
5186bool FTextAssetActions::HasActions (const TArray<UObject*>& InObjects) const
5287{
53- return false ;
88+ return true ;
5489}
5590
5691
@@ -73,5 +108,4 @@ void FTextAssetActions::OpenAssetEditor(const TArray<UObject*>& InObjects, TShar
73108}
74109
75110
76-
77111#undef LOCTEXT_NAMESPACE
0 commit comments