I have this running on the Update() on Unity. I am trying to create a page swipe feature on my game, but the problem is there is a half second delay when printing "dragging" to "end drag" when I release the mouse.
Does anyone have a method that will register input events faster?
void Update()
{
if(isDragOn)
{
if(Input.GetMouseButton(0))
{
print ("dragging");
//moveContainers((Input.mousePosition.x - mouseLastPosition) * 0.01f);
mouseLastPosition = Input.mousePosition.x;
}
else if(Input.GetMouseButtonUp(0))
{
print ("end drag");
isDragMoved = false;
isDragOn = false;
endDrag();
}
else if(Input.touchCount > 0)
{
if(Input.GetTouch(0).phase == TouchPhase.Moved)
{
//moveContainers(Input.GetTouch(0).deltaPosition.x);
}
else if(Input.GetTouch(0).phase == TouchPhase.Ended)
{
isDragMoved = false;
isDragOn = false;
endDrag();
}
}
}
}
end dragis printed immediately when I release the mouse. I suggest you do some further debugging/optimization. \$\endgroup\$Updatefunction. Every script on every object has anUpdatefunction, they all get run every frame. You may have too many objects, or one of your scripts has anUpdatefunction that takes a very long time to complete. \$\endgroup\$