Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import SwiftUI
import RealityKit
struct MaterialsView: View {
let model: ModelEntity
var body: some View {
Group {
ForEach(0..<(model.model?.materials ?? []).count, id: \.self) {
index in MaterialColourView(index: index, model: model)
}
}
}
}
struct MaterialColourView: View {
@State var colour = Color.clear
let index: Int
let model: ModelEntity
var body: some View {
ColorPicker("Material \(index)", selection: $colour)
.onChange(of: colour) { value in
model.changeMaterial(atIndex: index, toColour: colour)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment