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
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