Post

Replies

Boosts

Views

Activity

Passing variables from swiftUI view to RealityView with custom type.
Hello ! I'm working on an AR project using SwiftUI and RealityKit, and I've encountered a challenge. I need to pass a custom data type from a SwiftUI view to a RealityKit view(Full-Immersion). The data type in question is an Album, defined as follows: struct Album: Identifiable, Hashable { var id = UUID() var image: String var title: String var subTitle: String } Please help.
0
0
293
Apr ’24
Dynamically Loading USDZ Objects from an Array into a fully immersive Scene using Reality Kit
Hello, I am currently working on a project where I am creating a bookstore visualization with racks and shelves(Full immersive view). I have an array of names, each representing a USDZ object that is present in my working directory. Here’s the enum I am trying to iterate over: enum AssetName: String, Codable, Hashable, CaseIterable { case book1 = "B1" case book2 = "B2" case book3 = "B3" case book4 = "B4" } and the code for adding objects I wrote: import SwiftUI import RealityKit struct LocalAssetRealityView: View { let assetName: AssetName var body: some View { RealityView { content in if let asset = try? await ModelEntity(named: assetName.rawValue) { content.add(asset) } } } } Now I get the error, when I try to add multiple objects on Button click: Unable to present another Immersive Space when one is already requested or connected please suggest any solutions. Also suggest if anything can be done to add positions for the objects as well programatically.
1
0
751
Mar ’24