Reality View toggle Entities activation

I'm trying to create a feature in my app vision OS app where i show a reality view and on button click toggle different entities as in showing them on button click and vice versa. Is this possible in Vision os? if so how can i do this ? All that I did now was to instanciate my scene which contains a car 3d model, red tyres and blue tyres. On a button click i'm trying to show the blue tyres instead of the red ones.

Is this possible ? Thank you,

Hello,

Take a look at this small example, I recommend that you reference it to understand how you can manipulate your scene based on buttons, toggles, or other user actions:

import SwiftUI
import RealityKit

struct ContentView: View {
    
    let box = ModelEntity(mesh: .generateBox(size: 0.1), materials: [whiteMaterial])
    
    static let whiteMaterial = SimpleMaterial(color: .white, isMetallic: true)
    static let redMaterial = SimpleMaterial(color: .red, isMetallic: true)
    
    @State private var isOn = false
    
    var body: some View {
        VStack {
            RealityView { content in
                content.add(box)
            }
            
            Toggle("Color", isOn: $isOn)
                .toggleStyle(.button)
        }
        .padding()
        .onChange(of: isOn) { oldValue, newValue in
            
            if newValue {
                box.model!.materials[0] = Self.redMaterial
            } else {
                box.model!.materials[0] = Self.whiteMaterial
            }
            
        }
        
    }
}
Reality View toggle Entities activation
 
 
Q