Added convenience ext for hashing into uuid

This commit is contained in:
Franklin 2024-03-24 14:39:01 +01:00
parent c500dc9c42
commit 1ff7a7a23e
4 changed files with 15 additions and 2 deletions

2
Cargo.lock generated
View File

@ -608,7 +608,7 @@ dependencies = [
[[package]]
name = "bevy_icon_creator"
version = "0.1.1"
version = "0.1.2"
dependencies = [
"bevy",
]

View File

@ -1,6 +1,6 @@
[package]
name = "bevy_icon_creator"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Franklin E. Blanco"]
description = "A plugin to automatically create Icons from entities/models in bevy"

12
src/hash_to_uuid_ext.rs Normal file
View File

@ -0,0 +1,12 @@
use std::hash::{DefaultHasher, Hash, Hasher};
use bevy::utils::Uuid;
pub trait HashToUuidExt: Hash {
fn to_uuid(&self) -> Uuid {
let mut default_hasher = DefaultHasher::new();
self.hash(&mut default_hasher);
let hash = default_hasher.finish();
Uuid::from_u128(hash as u128)
}
}

View File

@ -5,6 +5,7 @@ mod state;
mod utils;
mod set_image_on_load;
mod register_types;
mod hash_to_uuid_ext;
pub mod image_ext;
pub mod plugin;