I want to alert my users if a sublayer is not loaded. Is there a method to check for unloaded layers? My current approach is to walk each layer/sublayer and check if each path in layer.sublayerPaths is in the layer.GetLoadedLayers list. Looking for a more performant or existing approach.
The “composition engine” underneath the UsdStage keeps track of the errors it encountered while (last re-)composing the stage, including which layers it could not find. The completion of the validation project we are undertaking will provide easier access to these errors.
If you are primarily interested in the missing “root layerstack” layers (which is what the technique you are currently using will give you), then after opening the stage, you should be able to get at the errors that will contain such information like (in python):
pr = stage.GetPseudoRoot()
# if root layer wasn't found then pr will be None
if pr:
errors = pr.GetPrimIndex().rootNode.layerStack.localErrors