1 (edited by Neil 2018-03-22 03:33:55)

Topic: Adding event trigger to OnlineMapsMarker3D

We are trying to add a GvrPointerPhysicsRaycaster so that when the white dot comes over one of the OnlineMapsMarker3D it should trigger the tooltip.  For that we have added GvrPointerPhysicsRaycaster to Main camera and then trying to add a collider and event trigger on every OnlineMapsMarker3D that is dynamically generated. However whenever we bring the white dot in front of the mater it does not turn into white circle (which will tell use that the event is triggered.) I am using following code, can you suggest what is the right way to add a event trigger to markers ?

                //Load and instantiate the prefab
                GameObject dynamicPrefab = Resources.Load (icon) as GameObject;

                OnlineMapsMarker3D marker = map3d.AddMarker3D (new Vector2 (lng, lat), dynamicPrefab);

                //Add colider
                var boxCollider = dynamicPrefab.AddComponent<BoxCollider>();
                //ADD EVENT TRIGGER 
                EventTrigger.Entry entry = new EventTrigger.Entry();
                entry.eventID = EventTriggerType.PointerEnter;
                entry.callback.AddListener((eventData) => { MyFunction(); });
                dynamicPrefab.GetComponent<EventTrigger>().triggers.Add(entry);

PS tooltip comes when I bring mouse over it but not when the raycaster is over it.

https://developers.google.com/vr/unity/ … sRaycaster

Post's attachments

Attachment icon Screen Shot 2018-03-22 at 9.00.55 AM.png 461.51 kb, 77 downloads since 2018-03-22 

Re: Adding event trigger to OnlineMapsMarker3D

Hello.

1. It does not matter because 2, but should be:
marker.instance.AddComponent<BoxCollider>();
2. The marker automatically creates a BoxCollider, if it does not have other colliders.
3. The marker sets Collider.isTrigger = true. Perhaps this is important.
4. Should be:
marker.instance.GetComponent<EventTrigger>().Triggers.Add(entry);

Kind Regards,
Infinity Code Team.

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

Re: Adding event trigger to OnlineMapsMarker3D

Thanks for reply. I changed it to following, still it did not work. The tooltip only comes when mouse if hovered not when white dot is brought on top of the marker.

                marker.instance.AddComponent<BoxCollider>();

                EventTrigger.Entry entry = new EventTrigger.Entry();
                entry.eventID = EventTriggerType.PointerEnter;
                entry.callback.AddListener((eventData) => { MyFunction(); });
                EventTrigger eventTrigger  = marker.instance.AddComponent<EventTrigger> ();
                eventTrigger.triggers.Add (entry);

Re: Adding event trigger to OnlineMapsMarker3D

Let's try to solve the problem from the other side.
Instead of trying to manipulate markers, just intercept the input.
Example:
http://infinity-code.com/atlas/online-m … ample.html

Kind Regards,
Infinity Code Team.

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