Topic: Remove custom tooltips

How to remove custom uGUI tooltips from the map when all markers are removed?

The example code doesn't seem to work when I call

OnlineMaps.instance.RemoveAllMarkers();

because "OnRemoveMarker" is not called.

Also, since the array containing all markers is created anew, the code in LateUpdate doesn't work either

        //empty, so no tooltip is destroyed
        foreach (OnlineMapsMarker marker in OnlineMaps.instance.markers)
        {
            if (string.IsNullOrEmpty(marker.label))
            {
                DestroyTooltip(marker);
                continue;
            }

            if (!marker.inMapView)
            {
                DestroyTooltip(marker);
                continue;
            }
        }

I figured I could just call "RemoveMarker", but for a lot of markers, calling Array.Resize every time is out of the question.

I also thought about just creating an extension method that calls "OnRemoveMarker" for every one

Bottom line, is there a way to clear all markers from the map and, at the same time, remove all custom tooltips? Is there an event somewhere that is called? Or is this something I have to implement by myself? (which is fine, btw, I am just curious)

Re: Remove custom tooltips

Hello.

Just remove the all tooltips before using RemoveAllMarkers.
Something like:

foreach (OnlineMapsMarker marker in OnlineMaps.instance.markers) DestroyTooltip(marker);
OnlineMaps.instance.RemoveAllMarkers();

If you remove the markers from another script, simply make a public method that will remove all tooltips.

Thank you for writing about OnRemoveMarker. We missed this point.

Kind Regards,
Infinity Code Team.

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

Re: Remove custom tooltips

Okay then, thanks for the tip!

On a side note, will "OnRemoveMarker" be invoked when calling "RemoveAllMarkers" in a future update?

Re: Remove custom tooltips

Yes. Actually, I already did it, and in future updates OnRemoveMarker will be invoked.

Kind Regards,
Infinity Code Team.

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