resolveRefKey method
Resolves a prefab refKey referenced by the scene at hostSourcePath to
a scene asset key. Prefab references are relative to the referencing
document (how the editor authors them), so this tries the reference joined
onto the host scene's directory first, then the reference as a
package-root-relative path (also accepted), throwing only when neither
resolves.
Implementation
String resolveRefKey(String hostSourcePath, String refKey, String? package) {
final dir = _dirOf(_sceneId(hostSourcePath));
if (dir.isNotEmpty) {
try {
return resolveKey(_joinScenePath(dir, refKey), package: package);
} on StateError {
// Not found relative to the host; fall back to the raw reference.
}
}
return resolveKey(refKey, package: package);
}