This crate provides a Bevy plugin for integrating with the Steamworks SDK.
|Bevy Version |bevy_steamworks| |:------------|:---------------| |git (main) |git (develop) | |0.6 |0.2, 0.3 | |0.5 |0.1 |
Add the following to your Cargo.toml
:
toml
[dependencies]
bevy-steamworks = "0.3"
Ensure that your build environment has all the needed requirements to use bindgen.
Download and install the steamworks sdk
and set the environment variable STEAM_SDK_LOCATION
to point to it.
To add the plugin to your app, simply add the SteamworksPlugin
to your
App
. This will require the AppId
provided to you by Valve for initialization.
```rust norun use bevy::prelude::*; use bevysteamworks::*;
fn main() { // Use the demo Steam AppId for SpaceWar App::new() .addplugins(DefaultPlugins) .addplugin(SteamworksPlugin::new(AppId(480))) .run() } ```
The plugin adds steamworks::Client
as a Bevy ECS resource, which can be
accessed like any other resource in Bevy. The client implements Send
and Sync
and can be used to make requests via the SDK from any of Bevy's threads. However,
any asynchronous callbacks from Steam will only run on the main thread.
The plugin will automatically call SingleClient::run_callbacks
on the Bevy
main thread every frame, so there is no need to run it manually.
NOTE: If the plugin fails to initialize (i.e. Client::init()
fails and
returns an error, an error wil lbe logged (via bevy_log
), but it will not
panic. In this case, it may be necessary to use Option<Res<Client>>
instead.
```rust norun use bevy::prelude::*; use bevysteamworks::*;
fn steamsystem(steamclient: Res
fn main() { // Use the demo Steam AppId for SpaceWar App::new() .addplugins(DefaultPlugins) .addplugin(SteamworksPlugin::new(AppId(480))) .addstartupsystem(steam_system) .run() } ```