DEVELOPERS BLOG

Make Your Unity Games Scoreloop Social

ANNOUNCEMENTS / 09.18.13 / rmadhavan

scoreloop_defaultui

Social is now an important aspect of many games, and Scoreloop has provided a great platform to integrate those features with ease. We are pleased to announce that Unity game developers can now add social gaming features to their BlackBerry 10 games using the new Scoreloop Social Unity Plugin. The plugin is available for free download at the Unity Asset Store. It provides the Scoreloop back-end services such as user profiles, leaderboards and achievements through the standard Unity Social API.

Before we dive in, lets get the basics out of the way:

1. Setup a Scoreloop account

Visit http://developer.scoreloop.com and create a new account. If you are a BlackBerry user and have a BlackBerry ID, there is no need to create a new account. Simply choose “Login with BlackBerry ID” and enter your BlackBerry ID credentials to be redirected to the Scoreloop account. You should now see various preferences to customize your social gaming options. If you already have an account and have already published titles using Scoreloop, you can choose your existing game from the drop down menu and customize it. If not, you can create a new game title under “BlackBerry.” If the game’s name is not already taken, a new game profile will be created.

Note: There is no need to download any external libraries from the Scoreloop portal for BlackBerry 10.

2. Download the plugin

Assuming you are set up for BlackBerry 10 development with Unity 4.2, the Scoreloop Social plugin can be downloaded from within the Unity Editor at “Window->Asset Store”.  Once downloaded and imported, all the resources, sample scripts and documentation required to get you started are available under the “ScoreloopSocial” folder in the Project tree window.

scoreloop social

3. Add Scoreloop game information

Your Unity game can start communicating with the Scoreloop server with the information in the “Game Overview” section in your Scoreloop account. The information looks something like this:

Platforms              BlackBerry Game ID               xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx Game Secret           xxxxxxxxxx Game Currency Code     IBI

The above information must be formatted as shown below and stored in your root of the Unity project tree under the folder “Resources” with a name “SLGame.txt”.

 // Scoreloop game properties "game.name"="A Scoreloop Game"; "game.id"=" xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx "; "game.secret"=" xxxxxxxxxx "; "game.currency"="IBI"; "game.version"="1.0"; "game.publisher"="Sample Company Inc.";  // Leaderboard definitions "leaderboard.Global" = "mode:0;title=Global Leaderboard";

Note: The mode of a leaderboard allows for flexibility in leaderboards for different game difficulties. You must have mode:0 for a single leaderboard.

4. Initialize Scoreloop

To have the Unity Social API use the Scoreloop back end, you need to initialize the Scoreloop Social client as shown below:

using Scoreloop.CoreSocial.API; ... // Use this for initialization void Start () { ... Social.Active = ScoreloopSocialClient.Create(); ... }

5. Setting up a Scoreboard

To setup a scoreboard for your game, you have to configure the “Score Definition” under your Game profile in the Scoreloop portal. The Score Definition screen lets you choose the score sorting order, score caps, score formats, game modes etc. You can also define custom score formats by creating a text file named “SLScoreFormatter.txt” in the “Resources” folder. A sample formatter file is included along with the “ScoreloopSocial/Resources” folder for your reference. More details on the custom score format can be found in the plugin documentation.

6. Setting up Achievements

Game achievements can be set up in the Scoreloop portal by creating new awards under the “Awards” section. Once an award is created, default assets are assigned to it. In order to use custom award icons, “Edit” the award and upload your “Achieved” and “Unachieved” icons to the Awards.

setting up achievements_scoreloop

Now download the achievements content as a .zip file by clicking “Download Bundle” and then the “download-json” button respectively. Save the contents of “SLAwards.bundle” into the Resources folder and rename “Info.json” to “Info.txt” (because Unity does not recognize  .json  file as an asset). As a final step, enable Read/Write permission to the icons (.achieved and .unachieved) from the Texture Inspector window as shown below:

2 texture 2ds import settings

7. Check out the TestScene

The sample “TestScene“ included with the plugin gives you a great template to build your UI interface on. You can easily modify the standard buttons to your custom game UI assets. Just a note that ShowDefaultLeaderBoardUI() and ShowDefaultAchievementUI() from the Unity Social API is currently not available on the BlackBerry 10.0/10.1 OS. However, it would become available after BlackBerry 10.2 OS update.

For more information on how to customize the incoming social data and setup achievements, refer to the “ScoreloopSocial.pdf in the “ScoreloopSocial” folder under the project tree window. To understand the fundamentals of Scoreloop, please refer to native Scoreloop SDK Documentation.

If you have any questions or comments about the Scoreloop plugin please post them at Unity BlackBerry Development  Forum or connect to me directly at rmadhavan@blackberry.com or on Twitter at @rmadhavan7.

Let the contest begin!

About rmadhavan