RealityKit attachments on macOS?

I'm building a SwiftUI+RealityKit app for visionOS, macOS and iOS. The main UI is a diorama-like 3D scene which is shown in orthographic projection on macOS and as a regular volume on visionOS, with some SwiftUI buttons, labels and controls above and below the RealityView.

Now I want to add UI that is positioned relative to some 3D elements in the RealityView, such as a billboarded name label over characters with a "show details" button and such.

However, it seems the whole RealityView Attachments API is visionOS only? The types don't even exist on macOS. Why is it visionOS only? And how would I overlay SwiftUI elements over a RealityView using SwiftUI code on macOS if not with attachments?

Answered by Vision Pro Engineer in 817450022

Hi @nevyn ,

Yes, the RealityView initializer with the attachments closure is for visionOS only. If this is something you'd like to see on macOS, I highly recommend filing an enhancement report at https://feedbackassistant.apple.com with your use case. Feel free to paste the FB number here and I'll make sure it gets routed to the right folks. This is great feedback that we'd love to get recorded.

On macOS, you can use a ZStacklike this:

ZStack {
   RealityView { content in 
        // ...
        content.add(entity)
   }
   Text("overlay")
}

This also works with a VStack, HStack, etc. Let me know if this helps you out!

Accepted Answer

Hi @nevyn ,

Yes, the RealityView initializer with the attachments closure is for visionOS only. If this is something you'd like to see on macOS, I highly recommend filing an enhancement report at https://feedbackassistant.apple.com with your use case. Feel free to paste the FB number here and I'll make sure it gets routed to the right folks. This is great feedback that we'd love to get recorded.

On macOS, you can use a ZStacklike this:

ZStack {
   RealityView { content in 
        // ...
        content.add(entity)
   }
   Text("overlay")
}

This also works with a VStack, HStack, etc. Let me know if this helps you out!

RealityKit attachments on macOS?
 
 
Q