Did you find this helpful?
Getting Started with Kongregate and Unity
This example shows minimal setup required to authenticate your players through Kongregate and Unity.
- Registered Kongregate account
- Familiarity with the Kongregate Developers Guide
- Registered PlayFab title
- Unity project with PlayFab configured for your title
- Unity WebGL support installed
- Familiarity with Login Basics & Best Practices guide
Setting up Kongregate App
Kongregate requires you to upload a preview version of the app, before you gain access to necessary API information. So we need to prepare an index.html file with the following content:
<!doctype html> <html lang="en-us"> <head></head> <body> <h1>Placeholder</h1> </body> </html>
Navigate to Kongregate website, select "Games" tab (1). Then click "Upload your game" button (2), as shown on the picture below:
A page to set up a new application will open. Make sure to type in the application name (1), description (2) and select a category (3). Submit the new app by clicking "Continue" button (4), as shown on the picture below:
You will be transferred to the application upload page. First and very important, make sure to save the URL from your web address bar. This will save you a lot of time trying to restore access to the application once you close the page.
Once this is done, select the prepared index.html file as your Game File (1) and set up the screen size (2). Make sure to accept all the required licenses (3). Upload your application by clicking "Upload" button in the bottom of the page (4), as shown on the picture below:
Once the preview opens, ignore the content and head straight to the API information, as shown on the picture below:
Locate the API Key and save it for later use.
Configuring PlayFab title
In your PlayFab Title Game Manager navigate to Add-ons (1), then locate and click "Kongregate" (2), as shown on the picture below:
A page will open, allowing you to set up Kongregate integration. Enter the API Key (1) you acquired in the previous section and hit "Install Kongregate" button (2), as shown on the picture below:
If given no error message, you have configured PlayFab title integration with your Kongregate application.
Setting up Unity project
Unity setup checklist:
- [OPTIONAL] Install PlayFab Editor Extensions
- Setup your TitleId in the PlayFabSharedSettings Scriptable Object
- For Unity 5.6+, please, download Kongregate Preloader WebGL Template and place it inside Assets/WebGLTemplates folder (2)
- For Unity < 5.6, please, download Kongregate Preloader WebGL Template 5.5- and place it inside Assets/WebGLTemplates folder (2)
Create your working scene. For the testing purposes, you may use a screen-scaling canvas (1) with a couple of text labels. We will need only one to display debug messages. Create an empty GameObject and rename it to "Kongregate" (2).
This GameObject will contain KongregateHandler component with a wired Text label for debug message:
The code for the KongregateHandler component is the following:
The only way you can truly test the integration is by uploading your prototype to Kongregate. Open the build window and make sure WebGL is selected (1). The open player settings (2), as shown on the picture below:
Inside player settings, locate WebGL build settings. Ensure you have a size set up correctly (1) and make sure to select Kongregate Preloader Template (2), as shown on the picture below:
Build the application and open the build folder. You will end up with index.html and a bunch of other files (depending on Unity version). Take all the files except index.html and place them inside a zip archive, as shown on the picture below:
Use the URL you saved earlier to access your application upload page. Select index.html as your Game File (1). Select the ZIP archive as Additional files (2). Accept the licenses and hit upload:
Once the preview opens, you should be able to see your game live with the message changing. In the end, the message should indicate successful login through PlayFab:
At this point, you have successfully integrated PlayFab and Kongregate.