I'm developing a VisionOS app and I'm trying to load a ModelEntity from a USDZ file which is inside my custom RealityKit package called R2UVisionOficial. But it keeps giving me an resourceNotFound error.
import RealityKit
import R2UVisionOficial
import ARKit
/* more code */
do {
let newEntity: Entity
//...
// Loads entity from USDZ inside package
newEntity = try await ModelEntity(named: "Salas", in: r2UVisionOficialBundle)
//...
return newEntity
} catch {
print("wtManager >>> **** FAILED to load entity:", error.localizedDescription)
throw error
}
I'm sure I have the Salas.usdz file in the root folder of my package and that I'm using the correct paths. However I keep getting the error:
Failed to find resource with name "Salas" in bundle
It's funny because when I try to load a USDA (scenes) from the same packages, it works fine. So I guess there's something to do with ModelEntity or USDZ files.
Can you please help me?
P.S. This issue is similar to https://developer.apple.com/forums/thread/746842?answerId=780415022#780415022
Hey @giovanniR2U,
When loading a USDZ inside of a Reality Composer Pro package, use Entity(named:in)
.
If you'd like us to consider adding the necessary functionality to have ModelEntity(named:in)
be able to load from Reality files, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number here.
If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?
If you need to use the ModelEntity(named:in:)
variation you can include your USDZ file inside your project rather than including it in the package.
Hope this helps,
Michael