Topic: Marker get events with Collider on Children

The project i am working on, uses markers with a lot of children, and most are mesh, so is necessary tu use mesh colliders.
But they are very variable, like lines and such.
Is there a way to make the press events work on children colliders?? Until now, all i get to work is with colliders on the root of the marker.

Re: Marker get events with Collider on Children


Theoretically, it is possible.
You need to create your own Control that inherits OnlineMapsTileSetControl class, and rewrite GetInteractiveElement method to get OnlineMapsMarkerInstanceBase from the parent GameObjects.

Practically - in most cases it’s easier and better do not use marker events.
Instead, implement custom events on GameObjects that have colliders.
To get a marker from the internal collider, use GetComponentInParent<OnlineMapsMarkerInstanceBase>().marker.

Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: Marker get events with Collider on Children

I take a look to the class you mentioned.
I found out that the OnlineMapsControlBase3D get the function.
And i could get just a small chance that work for every situation.

So if you are interested follow the code modification to get it working;

if (Physics.Raycast(activeCamera.ScreenPointToRay(screenPosition), out hit, OnlineMapsUtils.maxRaycastDistance))

            OnlineMapsMarkerInstanceBase markerInstance = null;

            markerInstance = markerInstance ?? hit.collider.gameObject.GetComponent<OnlineMapsMarkerInstanceBase>();
            markerInstance = markerInstance ?? hit.collider.gameObject.GetComponentInParent<OnlineMapsMarkerInstanceBase>();
            if (markerInstance != null)
                return markerInstance.marker;

Re: Marker get events with Collider on Children

This way it will look for the collider, if it could not found in the same object, it will then look on parent.
It's even possible to modify to get to the marker root. if necessary.