2D UI: Element Drag and Drop demo

I’m posting here a basic demo of 2D ‘screen space’ drag and drop using elements - hopefully it’s of use to someone else; it’s is not as easy as it sounds! The ‘scale’ property of screen is undocumented, and is needed to compensate for screen element local positioning when blend mode is set to ‘blend’.


Also in there is a basic hookup script for ElementDragHelper (pc | PlayCanvas API Reference), but this doesn’t seem to be functional at this time.

1 Like

Ah, you had issues with Screen to canvas as well? I think I ended up going screen to world and then world to canvas in an old project :thinking:

Yaustar, was the purpose of your little workaround to properly get the position of UI elements on the screen in terms of raycasting? I’ve had issues with this as well and I’m curious to know what you meant by this!

Ah, actually looking back on it, I was actually trying to do canvas to world for a top down, twin stick like shooter. So I was doing canvas to screen and then screen to world : https://playcanvas.com/editor/code/543988?tabs=11827165

1 Like