tutounityfr / rich-presence-discord-unity3d Goto Github PK
View Code? Open in Web Editor NEWProjet exemple d'utilisation de Rich Presence (Discord) dans Unity 3D.
Projet exemple d'utilisation de Rich Presence (Discord) dans Unity 3D.
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(); } }
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
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 :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.