Giter Club home page Giter Club logo

rich-presence-discord-unity3d's People

Contributors

tutounityfr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

rich-presence-discord-unity3d's Issues

Presence Manager disconnects when loading a scene where a presence manger is also present

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(); } }

Works for Unity Editor, but not IL2CPP Windows

Not sure if this will ever be seen but I will give it a shot:

NotSupportedException: IL2CPP does not support marshaling delegates that point to instance methods to native code. The method we're attempting to marshal is: DiscordPresence.PresenceManager::ReadyCallback
  at DiscordPresence.DiscordRpc.Initialize (System.String applicationId, DiscordPresence.DiscordRpc+EventHandlers& handlers, System.Boolean autoRegister, System.String optionalSteamId) [0x00000] in <00000000000000000000000000000000>:0 
  at DiscordPresence.PresenceManager.OnEnable () [0x00000] in <00000000000000000000000000000000>:0 

Shutdown en changeant de scène: résolution

Bon, on le sais tous, mais sur Unity nous utilisons plusieurs scènes, dont un menu.

Donc, si l'on place le Presence Manager dans le menu, le RPC va se lancer au démarrage du jeu.
Ensuite nous pouvons changer de scène et update le RPC depuis cette scène.
Mais si l'on revient sur le menu, le RPC va s'éteindre avec ce message: Discord: shutdown.

Donc, pour fixer cela, c'est très simple:
Nous allons créer une scène de chargement avec le Presence Manager et, quand ce Presence Manager est prêt, nous allons directement sur la scène de menu, et n'irons PLUS JAMAIS sur cette scène de chargement (sous peine de shutdown du RPC).

J'espère que ça aidera des gens :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.