- Home /
Question by
James.Hartman · Dec 16, 2013 at 09:57 PM ·
guiinputmouseeventevent-handling
EventType.MouseDrag not working in WebPlayer
EventType.MouseDrag works in WebPlayer while fullscreen but not inside the window. Other functionality works fine with mouse interaction. Only have this issue in WebPlayer. Using Pro.
void OnGUI ()
{
if(Event.current.type == EventType.MouseDrag && Time.timeScale>0)
{
float inputX = Event.current.delta.x/10;
float inputY= Event.current.delta.y/10;
if(hSliderValue+inputX > 0 && hSliderValue+inputX < 190)
hSliderValue += inputX;
if(vSliderValue+inputY > 0 && vSliderValue+inputY < 80)
vSliderValue += inputY;
camAim.transform.eulerAngles = new Vector3 (0f, hSliderValue, 0);
mainCam.GetComponent<SmoothCamera> ().height = vSliderValue;
}
}
Comment
This is a work around, don't really like it though because it is messy.` #if UNITY_WEBPLAYER
if(!Screen.fullScreen)
{
if(Input.Get$$anonymous$$ouseButtonDown(1) || Input.Get$$anonymous$$ouseButtonDown(0))
{
mouseDrag = Input.mousePosition;
}
if(Input.Get$$anonymous$$ouseButton(1) || Input.Get$$anonymous$$ouseButton(2))
{
inputX = mouseDrag.x - Input.mousePosition.x;
inputY = mouseDrag.y - Input.mousePosition.y;
if(hSliderValue+inputX > 0 && hSliderValue+inputX < 190)
hSliderValue += inputX;
if(vSliderValue+inputY > 0 && vSliderValue+inputY < 80)
vSliderValue += inputY;
camAim.transform.eulerAngles = new Vector3 (0f, hSliderValue, 0);
mainCam.GetComponent<SmoothCamera> ().height = vSliderValue;
}
}
#endif `