diff --git a/crates/bevy_asset/src/path.rs b/crates/bevy_asset/src/path.rs index 8cec8282e2e58..e9150c63a8834 100644 --- a/crates/bevy_asset/src/path.rs +++ b/crates/bevy_asset/src/path.rs @@ -187,3 +187,15 @@ impl<'a> From for AssetPath<'a> { } } } + +impl<'a> From for AssetPath<'a> { + fn from(asset_path: String) -> Self { + let mut parts = asset_path.splitn(2, '#'); + let path = PathBuf::from(parts.next().expect("Path must be set.")); + let label = parts.next().map(String::from); + AssetPath { + path: Cow::Owned(path), + label: label.map(Cow::Owned), + } + } +}