Slate Asset Drop Targets

I’m trying to figure out how to include an asset drop target into my editor plugin.
Here’s what the widget reflector is telling me I need:

According to the image above, the editor is using an SAssetDropTarget widget.
This is what I need in my plugin… But I can’t seem to figure out the correct arguments required in order to instantiate one:

I’ve been sifting through the engine source trying to find any occurrences where an SAssetDropTarget (or even just an SDropTarget) is created, but I can’t seem to find enough information.
Does anyone know the proper way to construct one of these widgets?

Did you find the answer?

I never solved this directly, and I can’t remember the specifics…
But I think I came up with a workaround which allowed me to grab thumbnails using the asset registry.
And then I simply made my own dropdown using FARFilters & slate code.
It was pretty involving, so I’m not even sure if it was the proper route to go.

Hi Michael,

I’m having the exact same issue here! Needing this functionality for a plugin but just can’t get it to work.
In the engine there are a couple of places that use SAssetDropTarget but using those as an example doesn’t help. It’s the exact same thing in my code but somehow it won’t recognize/compile it.
Would be great if someone from Epic could take a look at this and give us some clarification on how to set it up.

Kind regards,

Wolff

SAssetDropTarget belongs to EditorWidgets module. Did You include this module in your .cs build file?

Emaer, thanks for the suggestion,

I tried that but it did not change anything sadly. Have you had any succes using the SAssetDropTarget in a plugin or elsewhere?

Kind regards,

Wolff

I just saw this while I was myself trying to make an SDropTarget work, so I thought I would share my solution if anybody else stumbles upon this.

Actually it was as easy as adding this in my Slate code:



SNew(SDropTarget)
.OnAllowDrop_Raw(this, &MyClass::OnDropTargetAllowDrop)
.OnDrop_Raw(this, &MyClass::OnDropTargetInputDrop)


And the functions for the OnAllowDrop and OnDrop events look like this:



bool MyClass::OnDropTargetAllowDrop(TSharedPtr<FDragDropOperation> DragDropOperation)
{
    return true;
}

FReply MyClass::OnDropTargetInputDrop(TSharedPtr<FDragDropOperation> DragDropOperation)
{
    UE_LOG(LogTemp, Warning, TEXT("Drop operation detected!"));

    return FReply::Handled();
}


Then you can drag an asset from the content browser and it will call OnDropTargetInputDrop() once you drop it in your widget.

Hi illuMinatus87,

I was trying also to make a sort of dataasset initializer in slate and I want to be able to drop a data asset in the editor.

I followed your example withouth great success. Could you tell me if you included some something aside from the EditorWidgets module in the .cs file or why it might not properly work for me with the given code put inside a simple + SVerticalBox::Slot() ?

Thank you in advance !

Hey!

So are you getting a compiler error, or does it just not react if you drag and drop something?
If you are getting an error, could you post it? That might help in finding out if you are missing an include.

Hey illuMinatus87,

yup ițm getting a compiler error.

Here it is in more detail:


the vertical box is actually part of a SAssignNew(ToolkitWidget, SBorder),

and I have added #include “Editor/EditorWidgets/Public/SDropTarget.h”, along with the EditorWidgets module in the .cs file :D.

Thank you in advance illuMinatus87,

Slate and SlateCore modules must be added to build.cs and “SlateBasics.h” must be included.

**BrUnO XaVIeR ,
unfortunatly even after doing all of that. SLATE, SlateCore and **“SlateBasics.h” I still have the same errors.

Thank you BrUnO XaVIeR ,!

I think you have all the includes that you need. The “Error List” is often misleading. Could you have a look at the “Output” window in Visual Studio and post the error that you get there?

You should add something to the content of the SDropTarget. I have an STreeView in my DropTarget, but I think you can put any widget there. This will enable you to drag and drop onto the widgets in the Content:


SNew(SDropTarget)
.OnAllowDrop_Raw(this, &MyClass::OnDropTargetAllowDrop)
.OnDrop_Raw(this, &MyClass::OnDropTargetInputDrop)
.Content()

    SNew(STreeView)
    ...
]

But it should be able to compile without the “Content” part.

Edit: I just saw that you are probably missing an “&” before you’re delegate function. Like:



.OnAllowDrop(this, **&**FDataAssetReceiverEdModeToolkit::OnDropTargetAllowDrop)


Hey illuMinatus87,

Actually i noticed that myself and changed it.
Even so it still has the exact same behavior :

Yours truly,

Errorlist should be disabled to work with Unreal;
It reports a lot of fake errors on Unreal source because of EpicGames custom compilation process

It would help a lot if you could post the error/s that you get in the Output Window of Visual Studio. From the Error List it is hard to say what is wrong.

Here I present you the output screen as well :

Undefined “xxx_API” means your build.cs file isn’t including necessary modules to use that class.

Hey guys,

I tryed playing around with the dependencies and figuring this out. My logic is : Since SDropTarget is from EditorWidget we should include it in the public dependencies. Did this and I am still encountering some difficulties.

Here is a screenshot :

A lot of thanks to all of you ^^.

“FEditorStyle” is from another Editor module as well.
To use it, its module must be included to build.cs.