Skip to content

How to change which material is pointed to by Handle<ColorMaterial> #12383

Answered by alice-i-cecile
ViddeM asked this question in Q&A
Discussion options

You must be logged in to vote

I would store a central resource that lets you quickly and easily look up the handles:

#[derive(PartialEq, Eq, Hash)]
enum TileType {
   Grass,
   Stone,
   Dirt,
}

#[derive(Resource, Deref, DerefMut)
struct TileHandles(HashMap<TileType, Handle<ColorMaterial>>);

// Set your handles like
*tile_handle = tile_handles.get(TileType::Grass).unwrap().clone_weak();

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ViddeM
Comment options

Answer selected by ViddeM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants