Added convenience ext for hashing into uuid
This commit is contained in:
parent
c500dc9c42
commit
1ff7a7a23e
|
@ -608,7 +608,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bevy_icon_creator"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue