Reputation: 51
TL;DR
After upgrading from Google VR to Google Cardboard XR Plugin. Looking for documentation/advice on:
Background:
My current approach:
a. I set the distance of the reticle pointer
b. attach a collider to the object i want to make active and make this a trigger
c. add event triggers to the object. I use the pointerEnter and pointerExit event triggers
If the object is within range of the camera/reticle pointer, then it becomes active and my script runs. This generally first checks that the user remains focused on the object for e.g. 1-3 seconds (determined by my script), then action the rest of the script - this ensures that the object isn't selected by mistake. This works perfectly for my needs and is implemented consistently across my app
Result:
When I try to run this with the new plugin in my app, following the quick setup guide, I do get the expected behaviour; the reticle pointer changes state from a dot to a circle but I then get the following errors:
When I "look" at the interactive object
Failed to call function OnPointerEnter of class EventTrigger Calling function OnPointerEnter with no parameters but the function requires 1. UnityEngine.GameObject:SendMessage (string) CardboardReticlePointer:Update () (at ./Library/PackageCache/com.google.xr.cardboard@17e19f289a/Runtime/CardboardReticlePointer.cs:158) Failed to call function OnPointerExit of class EventTrigger
When I "look away" from the interactive object
Calling function OnPointerExit with no parameters but the function requires 1. UnityEngine.GameObject:SendMessage (string) CardboardReticlePointer:Update () (at ./Library/PackageCache/com.google.xr.cardboard@17e19f289a/Runtime/CardboardReticlePointer.cs:167)
I did find this post but don't know if it is relevant since I don't understand the solution and definitely don't feel comfortable changing Google code without a bit of hand holding
Error says function requires 1 parameter when it actually requires none
So please can you help with the following:
How do i implement reticle pointer + collider + onPointerEnter/onPointerExit event handlers in the Editor (not code) to execute the script assigned to that object without having to change hundreds of objects to a different approach?
Given it works when I replace the Event Triggers in the Editor with code, I think I just need to know:
Please let me know if anything isn't clear or you need more information
thanks
Upvotes: 0
Views: 261
Reputation: 32
The Reticle included in the HelloCardboard demo scene is sending "OnPointerEnter", and "OnPointerExit" messages to the objects in the UI layer the ray hits, which the EventTrigger doesn't respond to.
You can write your own super simple MessageTrigger class to respond to those messages sent form the reticle, and use that instead of the EventTrigger component. That is a C# script with these two methods: public void OnPointerEnter(), and public void OnPointerExit().
Or you could use a PhysicsRaycaster, and extend the Event System Input to make the reticle work with the standard EventTrigger.
Descriptions can be found for example in this Cardboard SDK forum thread: https://github.com/googlevr/cardboard/issues/140
Upvotes: 0