Skip to content
Snippets Groups Projects
Verified Commit 0d4602c5 authored by Louis's avatar Louis :fire:
Browse files

Include weirdboi_tween support

parent 478c1b69
Branches trunk
No related tags found
No related merge requests found
......@@ -3022,6 +3022,26 @@ dependencies = [
"bevy_sprite",
"bevy_text",
"bevy_ui",
"weirdboi_tween",
]
[[package]]
name = "weirdboi_tween"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427af3fddbb65e5d6dba9114f65faf5cf9f2848eed42af44477dabd260499264"
dependencies = [
"bevy_app",
"bevy_color",
"bevy_derive",
"bevy_ecs",
"bevy_math",
"bevy_sprite",
"bevy_text",
"bevy_time",
"bevy_transform",
"bevy_ui",
"log",
]
[[package]]
......
......@@ -10,13 +10,17 @@ default = ["reflect", "ui", "sprite"]
reflect = ["dep:bevy_reflect"]
ui = ["dep:bevy_ui", "dep:bevy_text", "dep:bevy_color"]
sprite = ["dep:bevy_sprite", "dep:bevy_color"]
tween = ["dep:weirdboi_tween"]
[dependencies]
bevy_ecs = "0.16"
bevy_app = "0.16"
bevy_math = "0.16"
bevy_reflect = { version = "0.16", optional = true }
bevy_ui = { version = "0.16", optional = true }
bevy_text = { version = "0.16", optional = true }
bevy_sprite = { version = "0.16", optional = true }
bevy_color = { version = "0.16", optional = true }
\ No newline at end of file
bevy_color = { version = "0.16", optional = true }
weirdboi_tween = { version = "0.1.0", optional = true }
\ No newline at end of file
......@@ -83,4 +83,12 @@ impl HandlesTreeOpacity for MyCustomRenderable {
pub fn my_plugin(app: &mut App) {
app.register_opacity_type::<MyCustomRenderable>();
}
```
\ No newline at end of file
```
## `weirdboi_tween`
Enabling the optional feature `tween` allows this library to integrate with `weirdboi_tween`'s "tween anything" system
using the `TweenTreeOpacity` zst.
For use with other methods of tweening, animation, etc - TreeOpacity implements `Ease` from `bevy_math`, which should ease
integration
\ No newline at end of file
......@@ -7,10 +7,14 @@ pub mod presets;
mod bevy_ui_ext;
#[cfg(feature = "sprite")]
mod bevy_sprite_ext;
#[cfg(feature = "tween")]
mod weirdboi_tween_ext;
pub use opacity_tree::{
HandlesTreeOpacity, IgnoreOpacity, ObserveOpacityTreeExt, OpacityChanged, TreeOpacity,
};
#[cfg(feature = "tween")]
pub use weirdboi_tween_ext::TweenTreeOpacity;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, SystemSet)]
#[non_exhaustive]
......@@ -45,5 +49,10 @@ impl Plugin for TreeOpacityPlugin {
{
app.register_type::<TreeOpacity>();
}
#[cfg(feature = "tween")]
{
weirdboi_tween::RegisterTweenableExt::register_tweenable::<TweenTreeOpacity>(app);
}
}
}
use weirdboi_tween::Tweenable;
use crate::TreeOpacity;
pub struct TweenTreeOpacity;
impl Tweenable for TweenTreeOpacity {
type Comp = TreeOpacity;
type Data = f32;
fn current_value(cmp: &Self::Comp) -> Self::Data {
cmp.opacity()
}
fn update_component(cmp: &mut Self::Comp, value: Self::Data) {
cmp.set_opacity(value);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment