I am displaying an image on a plane after loading it from URL in visionOS app. It works fine, but I am getting this warning:
baseColor
was deprecated in visionOS 1.0: use color
property instead
static func fetch(url: String) {
let remoteURL = URL(string: url)!
let fileURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
let data = try! Data(contentsOf: remoteURL)
try! data.write(to: fileURL)
do {
let texture = try TextureResource.load(contentsOf: fileURL)
var material = SimpleMaterial()
material.baseColor = MaterialColorParameter.texture(texture)
} catch {
print(error.localizedDescription)
}
}
If I try to fix it by doing this:
material.color = MaterialColorParameter.texture(texture)
I get this error:
Cannot assign value of type 'MaterialColorParameter' to type 'SimpleMaterial.BaseColor' (aka 'PhysicallyBasedMaterial.BaseColor')
Do you know where might be the problem? Thanks!
SimpleMaterial.BaseColor
(iOS 15+) is a different type than SimpleMaterial.MaterialColorParameter
(iOS 13+). You can't assign different types to each other. Try this:
do {
let texture = try TextureResource.load(contentsOf: fileURL)
var material = SimpleMaterial()
material.color = SimpleMaterial.BaseColor(tint: .white, texture: .init(texture))
}