Low level native plugin in Apple VisionOS

Is low level native plugin working in Apple VisionOS? I tried but the UnityPluginLoad function is never called.

Hi there! Thanks for reaching out and sorry to hear you’re having trouble.

How have you implemented this native plugin? Did you base it on the NativeRenderingPlugin example? You should be able to follow what is implemented there for iOS to get things working. In particular, note the extra RegisterPlugin.mm file included to explicitly call UnityPluginUnload at the appropriate time. This is also necessary on visionOS.

Thanks for the reply.

Yes, I am doing exactly the same as the example, including the RegisterPlugin.mm file. The same code works fine on iOS, but it does not work on VisionOS

And is RegisterPlugin.mm set up to build on visionOS in the import settings? Same goes for your library. If you put a NSLog call in RegisterPlugin.mm is it called?

Are you building for MR or VR? Can you try in a Windowed build?

More generally, why do you need UnityPluginLoad to be called? Can you call it manually from C#?

@mtschoen It looks like we’re hitting same issue as the original poster. I’ll add some more details since it’s fresh thread.

We’re also not getting a call to UnityPluginLoad. From iOS example (NativeRenderingPlugin) this call happens from Unity side and passes in IUnityInterfaces that are then used to get graphics device. It can not be be made from managed side from my understanding.

The call to shouldAttachRenderDelegate happens correctly in RegisterPlugin.mm

Changing to windowed mode in XR Plugin-management does not make it work.

Worth noting that other calls from RenderingPlugin.cpp do happen correctly. Eg GetRenderEventFunc (native unity side calls into that) and also managed P/Invoke also happens eg SetTimeFromUnity. But still without call to UnityPluginLoad rendering can’t happen.

As a side I also did build NativeRenderingPlugin for visionOS - without adding PolySpatial or Apple visionOS from XR Plug-in Management just to get it as close to iOS example as possible. That actually did work on Vision Pro and rendered as windowed app (and metal rendering part also did work showing triangle and ‘wavy’ plane).

So looks like it is possible to get that example to work on device but not with Poly Spatial / XR Plugin.

We’re quite blocked on this one and it’s preventing us from using Unity for wider migration, we’re really keen to get past though this one though!

Unity 2022.3.21, Polyspatial 1.1.4

Hope that’s enough details to get you guys going - please let me know if there’s any more details that could be helpful.