ProwlEngine / Prowl

An Open Source C# 3D Game Engine under MIT license, inspired by Unity and featuring a complete editor and built on Silk.NET
MIT License
360 stars 30 forks source link

[Editor] Drag & Drop API #57

Closed michaelsakharov closed 9 months ago

michaelsakharov commented 9 months ago

As of now, we're using ImGUI directly resulting in duplicate code and some weird hacky'ish stuff.

Ideally, we have a singular clean API to handle all our Drag and Drop content. Something like:

//ImGUI Widget Here
if(DragAndDrop.RecieveAsset<Texture2D>(out AssetRef<Texture2D> droppedTex))
{
}
//ImGUI Widget Here
if(DragAndDrop.RecieveReference<Texture2D>(out Texture2D droppedTex))
{
}

//ImGUI Widget Here
DragAndDrop.OfferAsset<Texture2D>(offeredTex);
//ImGUI Widget Here
DragAndDrop.OfferReference<Texture2D>(offeredTex);

For dropping files into the editor from outside we should first import the asset. This should only be called on the window that should receive it not sure how to do that just yet with this style of API.

if(DragAndDrop.RecievedFromOutside<GameObject>(out Guid assetid))
{
}

Using this we can do additional things, like drawing a rectangle over the widget when dragging/dropping stuff.