WASM Bevy Resource interface #7523
-
Hello, May I ask you how to access and change a Bevy Resource using wasm? Example: #[wasm_bindgen] Thank you very much! Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello! Firstly, you will need to install the rust support for Wasm, very easily and accessible with a simple: rustup target install wasm32-unknown-unknown Then, you will need to install a cargo tool for the Wasm server, which also can be done very easily with a simple: cargo install wasm-server-runner After that, you will need to add it to your cargo.toml, simply add: [target.wasm32-unknown-unknown] Now, you will need to set the env variable for the runner by simply typing: export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-server-runner Finally, you can run it using: cargo run --target wasm32-unknown-unknown And of course build it with the wasm-bindgen tool, to generate all needed files to your wasm website, simply type both of these commands: wasm-bindgen --out-dir ./out/ --target web ./target/ Hope that helped(; |
Beta Was this translation helpful? Give feedback.
-
Your code seems to be wrong, if it's the issue so check it again or ask for my help(: |
Beta Was this translation helpful? Give feedback.
Hello!
Basically, you can read and learn it from the unofficial bevy book, but I will explain it here a lil bit.
Firstly, you will need to install the rust support for Wasm, very easily and accessible with a simple: rustup target install wasm32-unknown-unknown
Then, you will need to install a cargo tool for the Wasm server, which also can be done very easily with a simple: cargo install wasm-server-runner
After that, you will need to add it to your cargo.toml, simply add: [target.wasm32-unknown-unknown]
runner = "wasm-server-runner"
Now, you will need to set the env variable for the runner by simply typing: export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-server-runner
Finally, you …