Topic: 2D Marker interaction Events

Hi Alex,

Having some problems with events not being fired when clicking on any 2D markers in a Tileset map. In my current project everything was working as expected at first, but today the events have stopped being fired - both OnClick and OnDoubleClick - all I have done is reorder my hierarchy but have not changed any scripts. Tooltips still show for markers but not events hmm

Here is the code I am using (which was working until this afternoon):

public class MarkerEventHandler : MonoBehaviour
{
    public delegate void ClickAction(OnlineMapsMarkerBase marker);
    public static event ClickAction markerClickedEvent;
   
    // Use this for initialization
    void Start ()
    {
        OnlineMaps api = OnlineMaps.instance;
       
        foreach(var marker in api.markers)
        {
            marker.OnClick += OnMarkerClick;
           
            Debug.LogFormat("Marker {0} found",marker.label);
        }
    }
   
   
    private void OnMarkerClick (OnlineMapsMarkerBase marker)
    {
        Debug.Log(marker.label);
       
        if(markerClickedEvent != null)
            markerClickedEvent(marker);
    }
}

The Debug.Log in Start() shows the name of the marker but OnMarkerClick() doesn't get called??

This same thing happened on a separate project the I was experimenting with as well so I tried making a unity package of all the assets and loaded it not a new project, but the same problem existed (no marker events). Only after creating a totally new project and importing the assets one by one could I get it to work ...

Have you come across this happening before? Have you any suggestions for what it might be and how I might fix it? It's quite a large project and I really don't want to have to start over again.

Thanks

Re: 2D Marker interaction Events

Ok so even if I create a new scene in the project and add only the components needed to listen for OnClick events nothing happens - but if I create a completely new barebones project then marker events are fired as expected ...

Re: 2D Marker interaction Events

Hello.

Most likely you have some other collider over the map.
Use Physics.RaycastAll, to find the collider, which causes a problem.
http://docs.unity3d.com/ScriptReference … stAll.html

Kind Regards,
Infinity Code Team.

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

4 (edited by nigel.moore 2015-11-19 17:43:53)

Re: 2D Marker interaction Events

Hi

Thanks for the response but I have no objects with colliders in the scene, just a camera, a game object with the OnlineMaps components on it and a game object with the MarkerEventHandler script attached - however I did attach a script to the camera to check using RaycastAll and it finds nothing.

Re: 2D Marker interaction Events

Very interesting.
Please send to support a scene in which we can check it.

Kind Regards,
Infinity Code Team.

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

Re: 2D Marker interaction Events

OK will do, thanks.