Closed mastef closed 3 years ago
Personally, my unity editor closed when I called Dispose in OnApplicationQuit I think. Also I think this issue persists for the build player as well, not just the editor.
Actually using the Dispose causes a crash, not a graceful exit. The stack trace is huge.
What I've done is cleaning up the GameObject it is attached to with discord.Dispose()
.
Everything with the discord code is wrapped in a try{}catch(){} anyway, with the catch
code destroying the object. Then OnDisable is called.
Since there are unexpected crashes, like discord sdk crashing if there's no discord running in the background, although it was initialized with the Discord.CreateFlags.NoRequireDiscord
option. Or if the user closes Discord while playing the game, etc. We don't want any of this to bubble up to the game.
Related issue https://github.com/discord/discord-rpc/issues/13
Maybe the RunCallbacks() function doesnt execute between the ClearActivity and Dispose?
So far it seems that calling discord.Dispose()
works well.
When using the Discord GameSDK with the UnityEditor, the presence is not cleared up the moment the UnityEditor is exiting the play mode. Also when re-starting the Playmode, the Discord presence is still stuck, and doesn't receive the updates from the new session.
For this purpose it would be beneficial to call something like
Discord.Shutdown()
manually ( e.g. inOnDisable()
of my gameobject ) to clear the discord state.Tried with
Activity.clearActivity()
ordiscord.Dispose()
but that doesn't fully clear the game state in Discord - the user still shows up as "Playing Gamename" and further updates from a new session are ignored until either restart of Discord or UnityEditor.Another use-case is to use this method when an error happened and to clean up the connection properly.
In the RPC SDK it seems that there was a "shutdown" method for this.