I’ve been developing a plugin for unreal engine to work in the editor. I need to be able to drag a model or group of models, to allow the program to reference and later spawn those objects. I’ve had enough fun reading the documentation.
This is what i tried. Most of this code is derived from the example code given when creating a new plugin.
static FReply OnDropped(int itemTypeValue)
{
USelection* SelectedActors = GEditor->GetSelectedActors();
// Let editor know that we're about to do something that we want to undo/redo
GEditor->BeginTransaction(LOCTEXT("SPAWN_Actor", "Create Actor"));
//code to spawn
GEditor->EndTransaction();
return FReply::Handled();
}
static TSharedRef<SWidget> MakeItemBox(UStaticMesh itemObject, int itemTypeValue)
{
return SNew(SDragAndDropVerticalBox)
.ToolTipText("Drop asset into box")
.OnAcceptDrop_Static(&Locals::OnDropped, itemTypeValue);
}
…
+ SVerticalBox::Slot()
.HAlign(HAlign_Center)
.AutoHeight()
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.HAlign(HAlign_Left)
.AutoWidth()
[
SNew(STextBlock)
.Text(LOCTEXT("LevelsNumber", "No. Levels: "))
]
+ SHorizontalBox::Slot()
.HAlign(HAlign_Left)
.AutoWidth()
[
Locals::MakeItemBox(itemID = 7)
]
]
I am aware that this is incorrect. Any answers?