Contents

PresentationComponent

A component that presents a SwiftUI modal presentation from a RealityKit entity.

Declaration

struct PresentationComponent

Overview

Popovers that this component presents initially rotate themselves to face the active camera and appear with a breakthrough effect by default. To change the breakthrough effect on the presented view, use the presentationBreakthroughEffect modifier, like in the following example:

var presentationComponent = PresentationComponent(
    configuration: .popover(arrowEdge: .bottom),
    content: PresentedView()
        .glassBackgroundEffect()
        .presentationBreakthroughEffect(.prominent)
)

For presentations that opt out of breakthrough effects, consider applying breakthrough effects to the main elements of the view, to ensure that the occluding content doesn’t clip the content within the presentation:

HStack {
    Text(title)
        .breakthroughEffect(.subtle)

    Button(action: action, label: label)
        .breakthroughEffect(.subtle)
}
.glassBackgroundEffect()
.presentationBreakthroughEffect(.none)

To make the presentation continuously face the active camera, add a BillboardComponent to the same entity that contains the PresentationComponent:

entity.add(presentationComponent)
entity.add(BillboardComponent())

Topics

Structures

Initializers

Instance Properties

See Also

SwiftUI view attachments