Useful error message when two assets have the save UUID (#3739)
# Objective Fixes #2610 and #3731 ## Solution Added check for TYPE_UUID duplication in `register_asset_type` with an error message
This commit is contained in:
parent
0ccb9dd07e
commit
62329f7fda
@ -93,10 +93,19 @@ impl AssetServer {
|
||||
}
|
||||
|
||||
pub(crate) fn register_asset_type<T: Asset>(&self) -> Assets<T> {
|
||||
self.server.asset_lifecycles.write().insert(
|
||||
T::TYPE_UUID,
|
||||
Box::new(AssetLifecycleChannel::<T>::default()),
|
||||
);
|
||||
if self
|
||||
.server
|
||||
.asset_lifecycles
|
||||
.write()
|
||||
.insert(
|
||||
T::TYPE_UUID,
|
||||
Box::new(AssetLifecycleChannel::<T>::default()),
|
||||
)
|
||||
.is_some()
|
||||
{
|
||||
panic!("Error while registering new asset type: {:?} with UUID: {:?}. Another type with the same UUID is already registered. Can not register new asset type with the same UUID",
|
||||
std::any::type_name::<T>(), T::TYPE_UUID);
|
||||
}
|
||||
Assets::new(self.server.asset_ref_counter.channel.sender.clone())
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user