If you create a Presence Manager from the prefab in a scene and load to a scene where also a presence manager is present, the PresenceManager will disconnect from discord. This also happens, if you reload the scene if a presence manager is set up in this scene. This happens because the instance persists through different scenes (DontDestroyOnLoad in Awake())
Awake() checks if a presence manager (instance) already exists, and if so calls Destroy(gameobject). This leads to calling the OnDisable() function. In an instance has been previously created, the second (later) instantiation will be destroyed and call:
void OnDisable() { Debug.Log("Discord: shutdown"); DiscordRpc.Shutdown(); }
a possible solution is to replace with:
void OnDisable() { if (instance == this) { Debug.Log("Discord: shutdown"); DiscordRpc.Shutdown(); } }
If you create a Presence Manager from the prefab in a scene and load to a scene where also a presence manager is present, the PresenceManager will disconnect from discord. This also happens, if you reload the scene if a presence manager is set up in this scene. This happens because the instance persists through different scenes (DontDestroyOnLoad in Awake()) Awake() checks if a presence manager (instance) already exists, and if so calls Destroy(gameobject). This leads to calling the OnDisable() function. In an instance has been previously created, the second (later) instantiation will be destroyed and call:
void OnDisable() { Debug.Log("Discord: shutdown"); DiscordRpc.Shutdown(); }
a possible solution is to replace with:void OnDisable() { if (instance == this) { Debug.Log("Discord: shutdown"); DiscordRpc.Shutdown(); } }