Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
beast.672651's avatar
beast.672651
Honored Guest
3 years ago

Struggling with raycast interaction from oculus integration sdk

Hello guys, so I was trying to build a VR app. I was using oculus integration sdk. I know there is interactable unity event wrapper for assigning functions when an object is clicked using raycaster. When select event and we assign function by adding to the list in inspector. For me models are loaded at run time and I want to assign a function to the model when it is selected via raycaster through script. Like instead of adding in inspector, I want to assign a function to when select via script. How can I do it?. Struggling with this for hours now

1 Reply

Replies have been turned off for this discussion
  • Hello! I have the same issue. The problem is that the fields _whenHover, _whenUnhover, _whenSelect from the InteractableUnityEventWrapper script are all private, so there is no way to assign them through script other than modifying the sdk script directly. Another annoying problem is that if you want to assign a function to the InteractableUnityEventWrapper through the Editor (assign the serializable field), the script containing that function has to be in a prefab, or the object itself containing InteractableUnityEventWrapper has to be inside the Scene.

    Does anyone have a solution? Help please!

    [EDIT] I actually have an idea how you can solve this. So you have a prefab object that contains the scripts ColliderSurface, RayInteractable and InteractableUnityEventWrapper. To this prefab you have to also add the script that controls the events (InteractionManager.cs for example). Now that the interaction manager script is also attached to the prefab, you can assign its functions to the event fields. For example, if InteractionManager has a void OnPinch() method, you can assign it to the OnSelect() field of InteractableUnityEventWrapper manually through the Editor. Now that the connections have been done manually in the Editor, you can instantiate the prefab through script with no problems. Still, it is pretty dumb that you can not programatically build the gameobject, and you have to do it manually in the editor.