[WebGL] UI drag in Edge browser
Hi! My WebGL game is published on Facebook. I have an issue when Empty document icon randomly appears in Edge browser if I'm trying to drag some UI elements (buttons for example). My steps are: - press UI button and hold it (1-2 seconds) - drag mouse cursor when pressed - empty document icon appeared (marked with red frame on screenshot)
How can I avoid such behaviour? Looks like drag & drop function in Edge working with WebGL content.
I am also having this serious issue! And like 'CodeBear' said, for us the entire webgl window "pops" out and get's dragged around the screen like an image attached to the cursor!
We're seeing the same thing @hippogames . In our case, the entire game window gets dragged around and treated like a document or image (similar to what happens if you try to save an image to your computer by dragging it out of a web page onto your desktop). Any Unity folks have input?
Answer by Hogarth_BR · Jan 04, 2018 at 08:55 PM
@hippogames Try this, on your WebGL Template after loading the game do this: document.getElementsByTagName('canvas')[0].ondragstart = function() { return false; };
This worked for me.
Here's how to run stuff after loading the game:
<script>
var gameInstance = UnityLoader.instantiate("gameContainer", "%UNITY_WEBGL_BUILD_URL%",
{
onProgress: UnityProgress,
$$anonymous$$odule: {
onRuntimeInitialized: () => {
// Fix dragging sometimes showing an empty document / "not allowed" icon
document.getElementsByTagName('canvas')[0].ondragstart = function() { return false; };
}
}
});
</script>