I’m developing an editor tool that runs exclusively in playmode using the UI, as opposed to an editor window or the inspector.
I haven’t tried this yet, but should it be possible to drag and drop :
components (from inspector)
gameobjects(from hierarchy)
files from folders(eg textures)
objects(eg audiomixer)
from the editor onto the playmode UI and capture the references somehow?
I’m wondering if this is what I’m looking for?
https://docs.unity3d.com/ScriptReference/EventSystems.EventTrigger.html
Seems like you’d probably have to drag things from within the scene? Would you have to select the actual gameobject with a mouse from within the scene, or would dragging and dropping from inspector/hierarchy work?
Thanks
I’m sure that unity uses their static editor class DragAndDrop to transfer data between editor windows like the sceneview, inspector, heirarchy, and the project panels. Its how these windows communicate when you drag things around in the UI.
UnityObjects like components/assets/gameobjects are usually transfered via the static ObjectReferences array. When you access the array just test each element if its the exact type of unityobject you are expecting (as it can be any type of unityobject). While specialized non-unityobject classes are passed via GetGenericData() and SetGenericData().
When you drag things from those editor windows unity will fill DragAndDrop with the data you’re dragging. All you need to do is access DragAndDrop and accept the drag in your playmode UI so that other windows know that something has taken the data.
You can also drag things from your UI that other windows can use. Just PrepareStartDrag() to clear any previous drag data, add the objects you want to drag, then StartDrag() so that other windows know they can accept it.
1 Like