1 (edited by kmasaki 2021-02-15 16:02:54)

Topic: Zoom map by pinching in and out on mobile

I am looking for a way to zoom map by pinching in and out on mobile.
I found a script that solves the following problem

https://forum.infinity-code.com/viewtopic.php?id=1310

However, when I assigned the above script to a map object, it did not work.
I would like to know how to use it correctly.

I ran this environment on Unity Remote.
I am able to move the map by dragging on Unity Remote.

Re: Zoom map by pinching in and out on mobile

Hello.

Pinch to zoom is a built-in Online Maps behavior that is enabled by default and you don't need any script for this to work.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Zoom map by pinching in and out on mobile

Thanks for the reply.

The pinch-zoom function was built-in, as you said.
However, it did not work, so I will let you know the situation.

I checked the touch count in "UpdateGestureZoom()" of the "OnlineMapsControlBase" class, which is probably the pinch zoom process.

Please see the attached image.
There was a difference in the argument "touchCount" and "Input.touchCount".
When pinch zooming with UnityRemote, the "touchCount" value was 1 and the "Input.touchCount" value was 2.

If you have any advice, please let me know.

Re: Zoom map by pinching in and out on mobile

http://s.kota2.net/1613491543.png

Re: Zoom map by pinching in and out on mobile

http://s.kota2.net/1613491542.png

Re: Zoom map by pinching in and out on mobile

OnlineMapsControlBase.UpdateGestureZoom is called from OnlineMapsControlBase.Update, and touchCount is the value returned by OnlineMapsControlBase.GetTouchCount.

There can be two situations when GetTouchCount returns a value other than Input.touchCount:
1. You (some script) uses OnlineMapsControlBase.OnGetTouchCount, and returns a different value.
2. On your device Input.touchSupported returns false, and this method returns 1 when the left mouse button is pressed.
Don't be surprised that I write about a mouse on a mobile device, because:
https://docs.unity3d.com/ScriptReferenc … uches.html

You need to understand which case is yours and fix it.
Also, using OnGetTouchCount, you can force Online Maps to use your value (Input.touchCount).

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.