A growing set of macros which add some witchcraft into bevy, currently available: 🪄
- Style Sheet Notation for
bevy_uicomponents (and your own) -ui!(( width: 20px; )) - Simplified Notation for
Color,ValandUiRect-code!{ let red = #ff0000; //..any code }
[!IMPORTANT] This crate is meant to provide macros only - no additional bevy plugins, resources, components or systems
Simpler Hierarchy Spawning
Spawn children just by stating [] - the 'names' are just variables containing their Entity
- those variables can be used anywhere in the macro - even 'before'
- read more or see this example.
spawn!
CSS-like notation for bevy_ui
Using ui!((..)) (inner round braces) will return a tuple of mentioned components only.
- read about available fields, custom fields & notation in this readme
- see this example.
c.spawn;
//^ optional ? (or any token): hovering shows the returned tuple (if LSP used)
/// function as custom fields or p refabs
Code Replacement Macro
Using the code!{} macro simplifies constructing:
Colorby writing#rgb/#rgba/#rrggbb/#rrggbbaaValby writing0px/0%/0vw/0vh/0vmin/0vmax/@(auto)UiRectby writing[>0px]/[>0px 0px]/[>0px 0px 0px]/[>0px 0px 0px 0px](css-like)
So you can do fun things like:
let shadow = code!};
let color = code!;
// or multiple things in the macro
code!
println!
Version
Just to mention the obvious:
- Macros are token-based, meaning they aren't hard-bound to a specific bevy version
- However: These are mainly designed for bevy 0.15 and onwards
- The closer your bevy version is to 0.15, the more things will work
Design
Crates are separated into:
crate/*/syntax: token handling, meant to be reusablecrate/*: actual macros, based on that 'syntax'
[!NOTE] Only relevant if you dig deeper into this crate: The versions of those are not hard linked, since the macros can keep (or gain) features, even if the the syntax api has changed. So if one of those is
0.2.xand the other0.5.xat some point, don't worry.