msciotti / discord-game-sdk-test-apps

A repo full of various Discord GameSDK sample apps
67 stars 38 forks source link

Update DiscordController.cs with CreateFlags explanation #5

Open dogboydog opened 4 years ago

dogboydog commented 4 years ago

Hi, thank you for the sample apps. I was wondering if it would be good to update the Unity example with these comments from the starter guide. Personally I was very surprised that closing your game is the default behavior if discord can't be started, even with a try/catch (tested on ubuntu), so it's good to make this clear to save people some time. I wonder what the use case is for a game requiring Discord to start, but using the other flag is easy enough.

https://discord.com/developers/docs/game-sdk/sdk-starter-guide

/*
    Grab that Client ID from earlier
    Discord.CreateFlags.Default will require Discord to be running for the game to work
    If Discord is not running, it will:
    1. Close your game
    2. Open Discord
    3. Attempt to re-open your game
    Step 3 will fail when running directly from the Unity editor
    Therefore, always keep Discord running during tests, or use Discord.CreateFlags.NoRequireDiscord
*/
var discord = new Discord.Discord(CLIENT_ID, (UInt64)Discord.CreateFlags.Default);

Thank you