Bevy Hyda is a system that allows you to load HTML sites in your Bevy app/game. It is fully powered by BevyUI, so you can access, modify and use the elements like you do usually in Bevy! (without any 'but's).
First, make sure that you're using Bevy 0.14.0 (and up) in your project.
Clone the repository: git clone https://github.com/TheNachoBIT/bevy_hyda
Open your project's Cargo.toml and add it in dependencies:
# ...
[dependencies]
bevy = "0.14.0"
bevy_hyda = { path = "path/to/bevy_hyda" }
# ...
Done! Now you can build/run your project to see if everything's up and running as it should!
First, in your code, you add the HydaBevyPlugin
to your Bevy app with add_plugins()
.
After that, inside of a setup system that contains a mut Commands
and a Res<AssetServer>
(could've be an existing one or a new one, its up to you :D), initialize a HydaAST
by opening an HTML file with html_file()
or use a string with html_string()
:
let get_html = bevy_hyda::html_file("assets/path/to.html".to_string());
let get_html = bevy_hyda::html_string(r#"
<html>
<body>
<h1>Hello World!</h1>
</body>
</html>
"#.to_string());
Finally, we spawn the UI with spawn_ui()
, passing the commands and asset server to the function:
get_html.spawn_ui(&mut commands, &asset_server);
WARNING: Make sure that before spawning the UI, you have already any type of camera spawned in your scene.
And you're done! You can just build & run your project and you're going to see your wonderful HTML file displayed in Bevy! :D
If you want to see the full code, you can check out the examples folder in this repo!
If you want to contribute:
Aaaaaand i guess that's it! Thank you so much for reading and i hope you like Bevy Hyda! Have a great day/night! :D