This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::app::ScheduleRunnerPlugin; | |
use bevy::ecs::schedule::{ExecutorKind, ScheduleLabel}; | |
use bevy::prelude::*; | |
fn main() { | |
let mut app = App::empty(); | |
let mut schedule = Schedule::new(); | |
schedule.set_executor_kind(ExecutorKind::SingleThreaded); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::prelude::*; | |
use bevy::reflect::{ReflectFromPtr, ReflectMut}; | |
/// Example demonstrating how to print and mutate the resources of a world using reflection | |
fn main() { | |
App::new() | |
.init_resource::<AppTypeRegistry>() | |
.register_type::<Foo>() | |
.register_type::<Bar>() | |
.insert_resource(Foo::A) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::prelude::*; | |
use std::collections::HashSet; | |
/// Example demonstrating despawning all entities that were spawned during a specific state | |
fn main() { | |
let mut app = App::new(); | |
app | |
.add_state::<AppState>() | |
.insert_resource(EntityRecord(HashSet::new())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::app::AppExit; | |
use bevy::prelude::*; | |
use bevy::window::WindowCloseRequested; | |
fn main() { | |
App::new() | |
.init_state::<ExitState>() | |
.add_plugins(DefaultPlugins.set(WindowPlugin { | |
close_when_requested: false, | |
..default() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::prelude::*; | |
fn main() { | |
divan::main(); | |
} | |
#[divan::bench] | |
fn reflect() { | |
let mut input: Box<dyn MovementField> = Box::new(PlayerInput::default()); | |
for n in 1..=1000 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::File; | |
use std::io::{BufWriter, Read}; | |
use walkdir::WalkDir; | |
use foo::Foo; | |
/// Converts postcard `.post` files to bincode `.bin` files assuming they represent `Foo` data | |
fn main() -> anyhow::Result<()> { | |
let root = std::env::current_dir()?.join("data"); | |
for entry in WalkDir::new(&root).sort_by_file_name().into_iter().filter_map(|e| e.ok()) { | |
let path = entry.into_path(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[features] | |
default = ["tracy"] | |
tracy = [] | |
[dependencies] | |
tracing = "0.1" | |
tracing-appender = "0.2" | |
tracing-subscriber = { version = "0.3", features = ["env-filter"] } | |
tracing-tracy = "0.11.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::app::prelude::*; | |
use dyn_clone::DynClone; | |
pub trait AppExt { | |
fn add_all_plugins(&mut self); | |
} | |
impl AppExt for App { | |
fn add_all_plugins(&mut self) { | |
for plugin in inventory::iter::<AutoPlugin> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>BEVY</title> | |
<link data-trunk rel="copy-dir" href="assets" /> | |
<style> | |
body, html { | |
height: 100%; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bevy::prelude::*; | |
use bevy::reflect::{GetTypeRegistration, ReflectMut, Typed, TypeInfo}; | |
fn main() { | |
let mut app = App::new(); | |
app | |
.add_plugins(MinimalPlugins) | |
.register_type_data::<String, ReflectFoo>() | |
.register_type_data::<usize, ReflectFoo>() | |
.register_type_data::<bool, ReflectFoo>() |