Thanks for the script. Now this is much clearer to me.
1. In this case, using OnDrawTooltip is very expensive.
This action will be called every frame, for each visible marker.
Subscribe to OnlineMaps.OnMapUpdated, and update the tooltips only when the map is updated.
Something like:
private void Start() {
...
map.OnMapUpdated += OnMapUpdated;
...
}
private void OnMapUpdated()
{
foreach (OnlineMapsMarker marker in map.markers) DrawToolTipForMarker(marker);
}
private void DrawToolTipForMarker(OnlineMapsMarker marker)
{
TooltipData tdata = marker.customData as TooltipData;
if (marker.inMapView)
{
if (tdata == null)
{
// Create tooltip
}
// Update tooltip
}
else if (tdata != null)
{
// Destroy tooltip
}
}
public class TooltipData
{
public GameObject instance;
public UIWidget widget;
...
// Any other data you need
}
2. You can store all the tooltip data in marker.customData.
3. If the marker is not on the screen, you need to destroy the tooltip.
Kind Regards,
Infinity Code Team.
Boost your productivity a lot and immediately using
Ultimate Editor Enhancer.
Trial and non-commerce versions available.