Post

Replies

Boosts

Views

Activity

Reply to RealityKit - Change Material Color or other properties in RealityView
@Vision Pro Engineer thanks for this, it helped a lot! For me and maybe it's because I was using a primitive from Reality Composer Pro, my entity's structure was a bit different: ⟐ SynchronizationComponent ⟐ CollisionComponent ⟐ InputTargetComponent ⟐ Transform ▿ 'usdPrimitiveAxis' : ModelEntity ⟐ SynchronizationComponent ⟐ ModelComponent ⟐ Transform So to get the model component I would have used: var model = cube.children.first?.components[ModelComponent.self] or also use this to get the index: let index = cube.children.firstIndex(where: { $0.name == "usdPrimitiveAxis"}) and then use that to get the reference from the children set
Topic: Graphics & Games SubTopic: RealityKit Tags:
Oct ’24
Reply to RealityKit - Change Material Color or other properties in RealityView
@Vision Pro Engineer thanks for this, it helped a lot! For me and maybe it's because I was using a primitive from Reality Composer Pro, my entity's structure was a bit different: ⟐ SynchronizationComponent ⟐ CollisionComponent ⟐ InputTargetComponent ⟐ Transform ▿ 'usdPrimitiveAxis' : ModelEntity ⟐ SynchronizationComponent ⟐ ModelComponent ⟐ Transform So to get the model component I would have used: var model = cube.children.first?.components[ModelComponent.self] or also use this to get the index: let index = cube.children.firstIndex(where: { $0.name == "usdPrimitiveAxis"}) and then use that to get the reference from the children set
Topic: Graphics & Games SubTopic: RealityKit Tags:
Replies
Boosts
Views
Activity
Oct ’24
Reply to SwiftData/ModelContainer.swift:144: Fatal error: failed to find a currently active container for Student
This only happens on the preview right? For a good explanation: https://www.hackingwithswift.com/forums/100-days-of-swiftui/day-54-crash-in-preview-of-swiftdata/26510/27172 TLDR; in the preview you're not initializing the container, so you'll need to: #Preview { ContentView() .modelContainer(for: Student.self) }
Replies
Boosts
Views
Activity
May ’24