Revision Difference
Installing_For_Unity#517233
<cat>installing</cat>⤶
<title>Installing For Unity</title>⤶
⤶
# File Placement⤶
⤶
Grab the latest version from the [Release Page](https://github.com/Facepunch/Facepunch.Steamworks/releases). Download the Facepunch.Steamworks file - not the source.⤶
⤶
Inside there's a Unity folder. Extract that to your project folder.⤶
⤶
<image src="https://files.facepunch.com/garry/e785935a-3ebf-4976-8cd6-670779be5f3f.png" />⤶
⤶
# Unity Config⤶
⤶
We have included the Unity .meta files in the zip file, so everything should be set up. The dlls should be assigned to the right platforms and should copy the dlls to the right locations on build.⤶
⤶
⤶
# Initializing⤶
⤶
To start up you just call Steamworks.SteamClient.Init with your appid. If it can't initialize it'll throw an exception - so make sure you catch that and deal with it.⤶
⤶
```⤶
try⤶
{⤶
Steamworks.SteamClient.Init( 252490 );⤶
}⤶
catch ( System.Exception e )⤶
{⤶
// Something went wrong - it's one of these:⤶
//⤶
// Steam is closed?⤶
// Can't find steam_api dll?⤶
// Don't have permission to play app?⤶
//⤶
}⤶
```⤶
⤶
<warning>You should only call this once on startup. Structure your code so this happens in your initialization code.</warning>⤶
⤶
# Running⤶
⤶
Every frame or so you should call RunCallbacks. This allows Steam to think and run any callbacks that are waiting.⤶
⤶
```⤶
void Update()⤶
{⤶
Steamworks.SteamClient.RunCallbacks();⤶
}⤶
```⤶
⤶
⤶
# Shutting Down⤶
⤶
When you're done call SteamClient.Shutdown.⤶
⤶
```⤶
Steamworks.SteamClient.Shutdown();⤶
```⤶
⤶
<warning>Steam won't actually show that you've stopped playing the game at this point. It doesn't do that until the exe and any child processes are closed. It sucks, but that's the way it is.⤶
⤶
This also means that in the Unity Editor it'll show as in game until you close the editor, but subsequent SteamClient.Init calls are needed and will work.</warning>