-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating an entity's NineSliceTexture doesn't update the material. #5
Comments
Here's a very small diff that fixes the issue for me. Not confident that this is a proper fix, but I'm going to be using this as a workaround and moving on for a bit. diff --git a/src/lib.rs b/src/lib.rs
index a20f17d..1c3d4b5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -98,7 +98,7 @@ fn sync_nine_slice(
}
fn spawn_nine_slice(
- nodes: Query<(Entity, &NineSliceTexture, &Node), Without<Handle<NineSliceMaterial>>>,
+ nodes: Query<(Entity, &NineSliceTexture, &Node), Changed<NineSliceTexture>>,
images: Res<Assets<Image>>,
mut cmd: Commands,
mut materials: ResMut<Assets<NineSliceMaterial>>, |
The texture component was intended to be used as a one-shot component. But this is stupid, I just ran into the same issue in my bevy jam game. I will change it to be a permanent component and sync the materials instead. Personally I also would love to have some additional shader capabilities, like a blend colors or even a color lookup table for easy to create hover effects, without the need of a new Image each time. Expect an overhaul very soon. |
That sounds great |
Everything I mentioned is now in the new version! The component is now synced, checkout the new Readme and examples |
Here's a reproducer that can be dropped in the examples directory.
Note that in the example below, I am only changing the texture, but this is also the case when switching between nine slices with the same texture but different bounds.
I am expecting the button to change visually when hovered.
The text was updated successfully, but these errors were encountered: