bertus wisman
bertus wisman

Reputation: 51

Unity mobile scrollrect too sensitive

i recently decided to make a 2D mobile game using Unity 5. now i have a problem with the scrollrect. it is way to sensitive on mobile. on windows my buttons in the scrollcontent work perfect. but on my phone i have hard times to press the buttons in the scrollcontent. i think it is because the scrollrect scrolls before the touch ends so it registers as a drag, and not a touch.

i tried to search on the internet for this problem but is seems to be a 2-3 year old problem that should been fixed.

i hope someone has the answer for my problem,

thanks.

Upvotes: 1

Views: 8277

Answers (3)

Ricky Martinez
Ricky Martinez

Reputation: 31

The actual question in hand here is how to stop the scrollview from scrolling from a very small amount of drag. This is particularly annoying on mobile devices, especially if you have a button in the scrollview, since the drag will cancel the button click. Adding a threshold with a script is unnecessary, since the event system already has a drag threshold. change that to a higher value to reduce sensitivity.

A better solution for mobile, would be to get the dpi from the screen

GetComponent<EventSystem>().pixelDragThreshold = baseThreshold*Screen.dpi/baseDPI

and set the eventsystem dragthreshold to some value based off of that.

Upvotes: 3

bertus wisman
bertus wisman

Reputation: 51

ok, i found a answer for my problem. after reading some more forums i came to the solution of add an event system. in the eventsystem i was able to modify the threshold, that did the trick.

Upvotes: 1

Programmer
Programmer

Reputation: 125285

If the ScrollRect is too sensitive on mobile devices then you have to change the properties of ScrollRect such as scrollSensitivity,elasticity,decelerationRate on mobile devices. You detect if app is running on mobile device then you change the values. The code below should do it.You may need to change the values to your needs.

void Start()
{
  if (Application.isMobilePlatform)
  {
      ScrollRect scrolRect = GameObject.Find("GameObjectScrollRectIsAttachedTo").GetComponent<ScrollRect>();
      scrolRect.scrollSensitivity = 0.5f;
      scrolRect.elasticity = 0.05f;
      scrolRect.decelerationRate = 0.2f;
  }
}

enter image description here

Upvotes: 4

Related Questions