init(make:update:placeholder:)
Creates a reality view for iOS and macOS, with an optional update closure and placeholder view.
Declaration
nonisolated init<P>(make: @escaping @MainActor @Sendable (inout RealityViewCameraContent) async -> Void, update: (@MainActor (inout RealityViewCameraContent) -> Void)? = nil, @ViewBuilder placeholder: () -> P) where Content == RealityViewCameraContent.Body<P>, P : ViewParameters
- 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. - placeholder:
A temporary view that the Realityview displays until your closure for the
makeparameter completes. For example, you can display a loading indicator with a Progressview instance as a placeholder.
Discussion
For example, your app can asynchronously load an Entity from a .reality or .usdz file, and display a ProgressView while the system loads the file:
RealityView { content in
if let newEntity = try? await Entity(named: "model_file_name") {
content.add(newEntity)
}
} placeholder: {
ProgressView()
}