-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: bevy 0.14 * docs: update for 0.2.0
- Loading branch information
Showing
13 changed files
with
206 additions
and
289 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[alias] | ||
run_wasm = "run --release --package run_wasm --" | ||
# Other crates use the alias run-wasm, even though crate names should use `_`s not `-`s | ||
# Allow this to be used | ||
run-wasm = "run_wasm" |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,22 @@ | ||
use async_std::task::sleep; | ||
use bevy::prelude::*; | ||
use bevy::{app::PanicHandlerPlugin, log::LogPlugin, prelude::*}; | ||
use bevy_async_task::{AsyncTask, AsyncTaskRunner}; | ||
use std::time::Duration; | ||
|
||
/// You can block with a task runner | ||
fn system1(mut task_executor: AsyncTaskRunner<u32>) { | ||
let result = task_executor.blocking_recv(async { | ||
sleep(Duration::from_millis(1000)).await; | ||
1 | ||
}); | ||
println!("Received {result}"); | ||
let result = task_executor.blocking_recv(async { 1 }); | ||
info!("Received {result}"); | ||
} | ||
|
||
/// Or block on a task, without the need of a system parameter. | ||
fn system2() { | ||
let result = AsyncTask::new(async { | ||
sleep(Duration::from_millis(1000)).await; | ||
2 | ||
}) | ||
.blocking_recv(); | ||
println!("Received {result}"); | ||
let result = AsyncTask::new(async { 2 }).blocking_recv(); | ||
info!("Received {result}"); | ||
} | ||
|
||
pub fn main() { | ||
App::new() | ||
.add_plugins(MinimalPlugins) | ||
.add_systems(Update, system1) | ||
.add_systems(Update, system2) | ||
.add_plugins((MinimalPlugins, LogPlugin::default(), PanicHandlerPlugin)) | ||
.add_systems(Startup, system2) | ||
.add_systems(Startup, system1) | ||
.run(); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[package] | ||
name = "run_wasm" | ||
publish = false | ||
|
||
[dependencies] | ||
cargo-run-wasm = "0.4.0" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/// Use [cargo-run-wasm](https://github.com/rukai/cargo-run-wasm) to build an example for web | ||
/// | ||
/// Usage: | ||
/// ``` | ||
/// cargo run_wasm --example [example_name] | ||
/// ``` | ||
/// Generally: | ||
/// ``` | ||
/// cargo run_wasm --example blocking | ||
/// ``` | ||
fn main() { | ||
cargo_run_wasm::run_wasm_cli_with_css("body { margin: 0px; }"); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
use bevy::prelude::*; | ||
use bevy::{app::PanicHandlerPlugin, log::LogPlugin, prelude::*}; | ||
use bevy_async_task::AsyncTask; | ||
use std::time::Duration; | ||
|
||
/// Use a timeout | ||
fn system() { | ||
let _timeout = AsyncTask::<()>::pending() | ||
AsyncTask::<()>::pending() | ||
.with_timeout(Duration::from_millis(1000)) | ||
.blocking_recv() | ||
.unwrap_err(); | ||
|
||
println!("Timeout!"); | ||
info!("Timeout!"); | ||
} | ||
|
||
pub fn main() { | ||
App::new() | ||
.add_plugins(MinimalPlugins) | ||
.add_plugins((MinimalPlugins, LogPlugin::default(), PanicHandlerPlugin)) | ||
.add_systems(Update, system) | ||
.run(); | ||
} |
This file contains 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
Oops, something went wrong.