From da485c29b3d0dc163e9116be573da1de40e658b3 Mon Sep 17 00:00:00 2001 From: andriyDev Date: Mon, 8 Jan 2024 14:17:29 -0800 Subject: [PATCH] Add `reserve_handle` to `Assets`. (#10939) # Objective Fixes #10938. ## Solution Adds `reserve_handle` to `Assets`. --- ## Changelog - Added `reserve_handle` to `Assets`. --- crates/bevy_asset/src/assets.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index bcb2cb7bf0..cc1ee6bf09 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -299,6 +299,11 @@ impl Assets { self.handle_provider.clone() } + /// Reserves a new [`Handle`] for an asset that will be stored in this collection. + pub fn reserve_handle(&self) -> Handle { + self.handle_provider.reserve_handle().typed::() + } + /// Inserts the given `asset`, identified by the given `id`. If an asset already exists for `id`, it will be replaced. pub fn insert(&mut self, id: impl Into>, asset: A) { let id: AssetId = id.into();