1 (edited by mikli1 2025-04-07 14:12:09)

Topic: Wrong zoom on point position calculation when hovering an UI marker

Hello,
I'm using markers with classic Unity UI. I'm not using any of the marker managers. I'm having a markers container just after the map texture in the hierarchy. I'm using a Map render texture and map camera that renders that texture on RawImage. I'm using OnlineMapsRawImageTouchForwarder.

When I hover over a marker and I use mouse scrollwheel the map zoom is changing. But the input position is wrong - it always zooms to (0, 0).

Is it somehow possible to fix that?

Wrong value comes from:
OnlineMapsRawImageTouchForwarder.OnGetInputPosition()
OnlineMapsControlBase.GetInputPosition()
OnlineMapsControlBase.HitTest()
OnlineMapsControlBase.UpdateZoom()


Also when my mouse is outside the raw image (on other part of the UI) mouse scroll wheel still is zooming the map, which is annoying. There should be a check whether I'm over the map on the UI.

Thanks for help

Re: Wrong zoom on point position calculation when hovering an UI marker

Hello.

Your problem requires a specific environment, without seeing which I will be looking for a black cat in a dark room.
If you send me your project for debugging by email (support@infinity-code.com), I will check what is not working correctly.
Otherwise, unfortunately, I don't know how to help you.

P.S. I don't need your working project.
Any temporary project where the bug shows itself is enough for me.

Kind Regards,
Infinity Code Team.

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

3 (edited by mikli1 2025-04-08 10:53:44)

Re: Wrong zoom on point position calculation when hovering an UI marker

I have kinda found a problem, the "target" in OnlineMapsRawImageTouchForwarder is storing a reference to my marker, and in the OnGetInputPosition() method there is a line that breaks the for loop iteration: "if (target != forwarder.image.gameObject) continue;"
Target is not equal to the map render texture raw image and it does not process the pointer position. When I comment this line is works correctly for me.



But the 2nd bug when using mouse scrollwheel while having the cursor outside my raw image is still present. The

return cl.Raycast(currentCamera.ScreenPointToRay(position), out lastRaycastHit, OnlineMapsUtils.maxRaycastDistance);

in OnlineMapsTileSetControl is returning true because the ray from map camera hits the map gameobject. But the correct check would be if a ray from my mouse cursor hits the raw image on the UI.

I've tried to do this with

var ped = new UnityEngine.EventSystems.PointerEventData(UnityEngine.EventSystems.EventSystem.current);
ped.position = Input.mousePosition;

List<UnityEngine.EventSystems.RaycastResult> hits = new();
UnityEngine.EventSystems.EventSystem.current.RaycastAll(ped, hits);

return hits.Any(x => x.gameObject.CompareTag("MapTexture"));

but somehow this is making the target zoom position wrong. I dont understand why.

Re: Wrong zoom on point position calculation when hovering an UI marker

I've sent you an email with a sample project where you can reproduce the bugs.