1 (edited by wuselrob 2025-07-30 13:57:33)

Topic: Marker Rendering Order Issues

Hey there smile

In our Unity game we have a custom marker sorting system where unsolved quest markers (priority 1) should always render on top of solved quest markers and team markers (priority 0) because sometimes when a team walks exactly to the quests location, the team marker overlaps the quest marker and blocks it from being clicked. This works correctly in some games but not consistently across all game types.

What We've Discovered:

1. Our Implementation:
- Custom IComparer<OnlineMapsMarker> that sorts by priority (unsolved = 1, solved/team = 0)
- Assigns markerComparer to OnlineMapsMarkerFlatDrawer
- Uses map.Redraw() to trigger re-sorting

2. How we think OnlineMaps v3 works Under the Hood:
- Markers are grouped by texture when creating materials
- Each texture group gets its own material/submesh
- Unity renders materials in the order they appear in the material array
- Click detection uses the original marker list order, not the visual rendering order

3. Our Attempted Solutions:
✅ Working: Custom MarkerComparer correctly sorts markers for visual rendering
❌ Problematic: Material reordering via OnSetMarkersMesh callback works visually but..
❌ Issue: Click detection doesn't match visual order when markers overlap (can't click my quest when there is another marker below it visually)

Current Status:
- Visual sorting works correctly (unsolved markers render on top)
- Click detection sometimes fails when markers overlap because hit-testing uses unsorted marker list
- Material order changes dynamically during map interactions

Questions:

OnlineMaps v4: Does v4 have better marker management that would solve this issue more elegantly?
OnlineMaps v3: Is there a built-in way to ensure marker click detection matches the visual rendering order?
Best Practices: What's the recommended approach for implementing custom marker sorting in OnlineMaps v3?

Technical Details:
- Using OnlineMaps 3.7.15.1
- Using OnlineMapsMarkerFlatDrawer with custom markerComparer
- Markers use different textures (team, solved quest, unsolved quest)
- Need unsolved quest markers to be both visually on top AND receive clicks when overlapping

Any insights or solutions would be greatly appreciated!
I hope the text is understandable smile

Have a great day!
Robert

Re: Marker Rendering Order Issues

Hi.

Online Maps v3 contains a bug in OnlineMapsMarkerFlatDrawer.GetMarkerFromScreen.
Thanks for showing me the problem.
I won't send you the entire script or patch because you are using a very old version of Online Maps.
Instead, I will show you the correct version of the method so you can modify it in your project.

public override OnlineMapsMarker GetMarkerFromScreen(Vector2 screenPosition)
    {
        if (usedMarkers == null || usedMarkers.Count == 0) return null;

        RaycastHit hit;
        Ray ray = control.currentCamera.ScreenPointToRay(screenPosition);
        if (!control.cl.Raycast(ray, out hit, OnlineMapsUtils.maxRaycastDistance)) return null;
        
        for (int i = usedMarkers.Count - 1; i >= 0; i--)
        {
            FlatMarker m = usedMarkers[i];
            if (m.Contains(hit.point, control.transform)) return m.marker;
        }

        return null;
    }
Kind Regards,
Infinity Code Team.

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