init(make:update:)
Creates a new reality view for visionOS with an optional update closure.
Declaration
nonisolated init(make: @escaping @MainActor @Sendable (inout RealityViewContent) async -> Void, update: (@MainActor (inout RealityViewContent) -> Void)? = nil) where Content == RealityViewContent.Body<RealityViewDefaultPlaceholder>Parameters
- make:
An asynchronous closure that configures the initial content of the new
RealityView. This closure is asynchronous to keep your app’s UI responsive while you load content to populate this view. - update:
An optional closure that updates the
RealityViewinstance’s content as the view’s state changes.
Discussion
Use the update closure to modify entities in the scene based on a Boolean state property, like in the following example:
RealityView { content in
content.add(boxEntity)
} update: { content in
boxEntity.scale = isEnlarged ? .one * 2 : .one
}