Compare commits
2 Commits
3fe21d45e9
...
57e8caa1b7
| Author | SHA1 | Date |
|---|---|---|
|
|
57e8caa1b7 | 1 year ago |
|
|
2d03309c4c | 1 year ago |
@ -0,0 +1,31 @@
|
|||||||
|
//! A minimal 2d example.
|
||||||
|
|
||||||
|
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
||||||
|
use bevy_mod_picking::prelude::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
App::new()
|
||||||
|
.add_plugins(DefaultPlugins.set(low_latency_window_plugin()))
|
||||||
|
.add_plugins(DefaultPickingPlugins)
|
||||||
|
.insert_resource(DebugPickingMode::Normal)
|
||||||
|
.add_systems(Startup, setup)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set up a simple 2D scene
|
||||||
|
fn setup(
|
||||||
|
mut commands: Commands,
|
||||||
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
|
) {
|
||||||
|
commands.spawn(Camera2dBundle::default());
|
||||||
|
commands.spawn((
|
||||||
|
MaterialMesh2dBundle {
|
||||||
|
mesh: meshes.add(Rectangle::default()).into(),
|
||||||
|
transform: Transform::default().with_scale(Vec3::splat(128.)),
|
||||||
|
material: materials.add(ColorMaterial::from(Color::PURPLE)),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
PickableBundle::default(), // <- Makes the mesh pickable.
|
||||||
|
));
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue