Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting unexpected "Tried to Initialize the SteamAPI twice in one session!" #657

Open
WildRikku opened this issue Nov 26, 2024 · 1 comment

Comments

@WildRikku
Copy link

I use Rich Presence in an OnDisable() to clear a text when a scene is unloaded. For a reason I cannot figure out, this causes SteamManager to throw the error for double initialization.

a) Am I safe to just comment out that error? I considered it a warning for bad coding style but I followed the recommendation there, which
b) might be outdated, as only using OnDisable() seems to no longer be sufficient.

This is in Unity 2021.3.39f1. SteamManager creates its GameObject and Component itself in the scene in question. I use the Enter Play Mode options with both reloads turned off.

@JamesMcGhee
Copy link
Contributor

SteamManager.cs is really more of an example script
You would typically be best to author your own script to handle initialization and running callbacks

For example, if you want to use Steam Input you would also want to RunInput, you might want to fetch leaderboard IDs, etc. all in that same process.

For our toolkit (built on top of Steamworks.NET) we don't actually like to use a MonoBehaivour to run callback or input at all rather we use a background worker. This eliminates quite a few issues including the problem of it being a GameObject in a scene that needs to be persisted.

Our toolkit has a free and open source "lite" version if you want to look at how we did it or use it as is
https://github.com/heathen-engineering/Toolkit-for-Steamworks-Foundation

Being a toolkit it does a lot ... if your only interesting in the initialization and running callbacks part check out the API.App.cs
https://github.com/heathen-engineering/Toolkit-for-Steamworks-Foundation/blob/main/Unity/com.heathen.steamworksfoundation/Runtime/API.App.cs

Again it does more than just init Steam client it also has logic for Steam Game Server and a few other bits but might be handy for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants