I’m writing a web player app, where the user can turn
an object by dragging with the mouse when a button
is pressed.
But when the mouse exits the web player the object
keeps turning - even when the user releases the button!
Why does Unity catch the movement events, but not the
button release event?
I am using Input.GetButton BTW, but
Input.GetMouseButton does not work either.
bringing back the old post, but I just have the same problem.
To recreate the problem:
hold “left mouse button” when mouse cursor is inside web player screen.
move cursor offscreen the web player (while still holding the left mouse button).
release “left mouse button” when cursor is outside the web player
go back inside the webplayer, Unity still detect that you still hold left mouse button (even though it’s released already).
Is there any solution so GetButton(“Fire1”) / GetMouseButton(0) will works correctly ?
EDIT:
just to be sure, this problem only happens on the Web version, Everything works normal/correctly inside the Unity Editor.
I attach a simple build of the problem,
basically you can rotate your camera only when you hold your left mouse button, try to hold and release the left mouse button outside web player screen to recreate the problem.
another thing,
the script itself is very simple, it’s just a slight modification of MouseLook.cs where the only part that i change is on Update()
void Update ()
{
// only do Mouse Look when player hold the left mouse button
if (Input.GetButton("Fire1"))
{
...
// Original Mouselook script here
...
}
}
i already tried another variation, but still has the same problem:
void Update ()
{
// only do Mouse Look when player hold the left mouse button
if (Input.GetMouseButton(0))
{
...
// Original Mouselook script here
...
}
}
I don’t know the solution to the problem here, but maybe you can circumvent it by not testing for the fire event, but for either Input.GetMouseButton() or even using the Event class instead?
I am very new in Unity3d. and I don’t know script.
I am trying to do architecture visualization.
I need that mouse movement as like your MouseProblem.zip.
and one question can I enable drag object script with your script.
Please help me by sending your modify script (file) or newly written script(file).
then i can use it directly into my scene.
also you can look at my done work about architecture visualization what I an trying.