Topic: Mask on the map

Hi everyone!

I have created an interface google maps like, I have inserted my 2d map in a canvas, then later i created a mask and i applied it on it to make the interface a little more pleasant, the problem is that the markers i generated, don't they seem to be maskable, so I can always interact with the markers even when I'm not with the pointer over the map,
Does anyone of you have an idea how to fix the problem and avoid interactions with markers when they are under the mask?

image

Post's attachments

Attachment icon phigital2.jpg 430.48 kb, 206 downloads since 2023-06-26 

Re: Mask on the map

Hi.

By default, tooltips are drawn with IMGUI, so this will be displayed on top of uGUI.
The best way in your case is to draw tooltips using uGUI.
Example:
https://infinity-code.com/atlas/online- … ample.html

Kind Regards,
Infinity Code Team.

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

Re: Mask on the map

Could you explain to me why this could solve my problem? Are the elements drawn through IMGUI are maskable? Cause i really need to add a Button properties to all of this tooltips!

Thanks!

Re: Mask on the map

This way will force the map draw tooltips using uGUI instead of IMGUI (by default).
IMGUI is not maskable.
uGUI is maskable.

Kind Regards,
Infinity Code Team.

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

Re: Mask on the map

Really thanks for the answare, but the problem is still there.

The main problem is that markers still have mouse events handled through IMGUI, since they are handled by the OnlineMapMarkerBase class, this means that when I hover over a marker, the mouse cursor is detected through the markerColliderRect , which I believe are always managed through IMGUI, and not UGUI. so this is not possible to disguise it, at least I think.
I also don't think markers are gameobjects, so you can't assign component buttons.

Re: Mask on the map

Markers are not drawn through IMGUI or uGUI.
In the Draw to Texture mode, the markers are drawn on the texture.
In Tileset mode, the markers are separate meshes.

I reread your first post several times carefully, and realized that I missed an important thing in your question: that you're asking about all interaction with markers, not just tooltips.
To disable all interaction with markers outside the mask, you need to override the marker drawer.
If you are using Drawing to Texture mode, you need to override OnlineMapsMarkerBufferDrawer.
If you are using Tileset mode, you need to override OnlineMapsMarkerFlatDrawer.

Something like:

using UnityEngine;

namespace InfinityCode.OnlineMapsSupport
{
    public class MaskedMarkerDrawer: MonoBehaviour
    {
        public OnlineMaps map;
        public RectTransform mask;

        private void Start()
        {
            if (map == null) map = OnlineMaps.instance;
            map.control.markerDrawer = new Drawer(map.control, mask);
        }

        public class Drawer : OnlineMapsMarkerBufferDrawer
        {
            private RectTransform mask;

            public Drawer(OnlineMapsControlBase control, RectTransform mask) : base(control)
            {
                this.mask = mask;
            }

            private bool IsPositionMasked(Vector2 position)
            {
                return RectTransformUtility.RectangleContainsScreenPoint(mask, position);
            }

            public override OnlineMapsMarker GetMarkerFromScreen(Vector2 screenPosition)
            {
                if (!IsPositionMasked(screenPosition)) return null;
                return base.GetMarkerFromScreen(screenPosition);
            }
        }
    }
}
Kind Regards,
Infinity Code Team.

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

Re: Mask on the map

I just want to tell you, thank you very much, just create an empty and assign the script you created and it works great!
Thanks a lot again!