26 releases (17 breaking)
0.23.0 | Aug 26, 2024 |
---|---|
0.22.0 | Jul 25, 2024 |
0.20.1 | Jun 18, 2024 |
0.16.0 | Mar 5, 2024 |
0.9.1 | Jul 19, 2023 |
#215 in Game dev
164 downloads per month
Used in haalka
190KB
2K
SLoC
bevy_cosmic_edit
This bevy plugin provides multiline text editing for bevy apps, thanks to cosmic_text crate!
Emoji, ligatures, and other fancy stuff is supported!
Usage
⚠️ Warning: This plugin is currently in early development, and its API is subject to change.
Explore examples folder for basic usage.
Native:
cargo r --example font_per_widget
Wasm:
cargo install wasm-server-runner
RUSTFLAGS=--cfg=web_sys_unstable_apis cargo r --target wasm32-unknown-unknown --example basic_ui
Compatibility
bevy | bevy_cosmic_edit |
---|---|
0.14.0 | 0.21 - latest |
0.13.0 | 0.16 - 0.20 |
0.12.* | 0.15 |
0.11.* | 0.8 - 0.14 |
License
MIT or Apache-2.0
lib.rs
:
bevy_cosmic_edit
Multiline text editor using cosmic_text
for the bevy
game engine!
This bevy plugin provides multiline text editing for bevy apps, thanks to cosmic_text crate! Emoji, ligatures, and other fancy stuff is supported!
Usage
Warning: This plugin is currently in early development, and its API is subject to change.
use bevy::prelude::*;
use bevy_cosmic_edit::*;
fn setup(mut commands: Commands, mut font_system: ResMut<CosmicFontSystem>) {
commands.spawn(Camera2dBundle::default());
// Text attributes
let font_size = 16.0;
let line_height = 18.0;
let attrs = Attrs::new()
.family(Family::Monospace)
.color(Color::DARK_GRAY.to_cosmic())
.weight(FontWeight::BOLD);
// Spawning
commands.spawn(CosmicEditBundle {
buffer: CosmicBuffer::new(&mut font_system, Metrics::new(font_size, line_height))
.with_text(&mut font_system, "Hello, Cosmic!", attrs),
sprite_bundle: SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(300.0, 40.0)),
..default()
},
..default()
},
..default()
});
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(CosmicEditPlugin::default())
.add_systems(Startup, setup)
.add_systems(Update, change_active_editor_sprite)
.run();
}
Check the examples folder for much more!
Native:
$ cargo r --example font_per_widget
Wasm:
$ cargo install wasm-server-runner
$ RUSTFLAGS=--cfg=web_sys_unstable_apis cargo r --target wasm32-unknown-unknown --example basic_ui
Compatibility
bevy | bevy_cosmic_edit |
---|---|
0.13.0 | 0.16 - latest |
0.12.* | 0.15 |
0.11.* | 0.8 - 0.14 |
Feature flags
License
MIT or Apache-2.0
Dependencies
~55–93MB
~1.5M SLoC