E-Skills Unity Plugin

This Guide will help you to integrate E-Skills platform in your unity game using the E-Skills unity package. Alternatively, you can implement it yourself following the generic integration guide.

Download package

Download the .unitypackage file from here.

Import package

  1. Assets -> Import package -> Custom package…
  2. Browse to the downloaded eskills.unitypackage file and choose it
  3. Press import

If the import was successful, you’ll be able to open our example scene by browsing to the file “Packages -> Eskills -> Scenes -> EskillsExample”. You can try it, change parameters and play around with it.

Join a Match

  1. Open the eskills prefab folder (Prefab -> Eskills) and add the Eskills prefab to your scene
  2. Inspect your “play” button
    a. Add a click event
    b. Drag the Eskills prefab on the scene to the On Click event
    c. Choose the function StartPurchase (EskillsService -> StartPurchase) to run once the player clicks the button
    d. Choose “1v1Match” asset menu as argument
581
  1. Setup custom android manifest (if you are using a custom manifest already you can skip to step 4)
    a. Edit->Project settings… -> Player -> Publishing Settings -> Build: check the Custom Main Manifest option
  2. Configure Eskills activity on Android Manifest
    a. Open the manifest file located at Assets/Plugins/Android/AndroidManifest.xml
    b. Add the following code inside the Application Tag
<Application>
...
<activity
    android:name="com.appcoins.eskills_purchase.PurchaseActivity"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" 
/>
...
</Application>

You can check an example on Assets/Plugins/Eskills/Android/AndroidManifest.xml path

  1. Receiving back the session token and start a match
    a. Extend OnMatchReadyResult class
    b. Implement “public void OnMatchReady(string session)” method
    c. Store the session string, it will be needed later on
  2. Start you game

❗️

Do not change the Eskills prefab name!

Changing the Eskills prefab name will prevent the match from starting.

Eskills Service

Eskills service is a class used to interact with eskills platform.
Currently it has 3 public methods:

  1. StartPurchase: Allows the developer to start a purchase process and join a room.
  2. GetRoomInfo: Fetches room data from the server
  3. SetScore: updates the user’s score in eskills platform

Add Eskills Service to your scripts

To add the EskillsService instance to your script you should do the following:

  1. Add Eskills prefab to the scene if needed
  2. Wherever you need to fetch room info, add a new field in the script as following:
[SerializeField] private EskillsService eskillsService;
  1. In the editor add the Eskills prefab as argument(dependency) of the script where you added the code on the previous step.

Fetch Room Status

As described in our guidelines, you should display the user’s score and the opponents’ score.

  1. Add Eskills prefab to the scene if needed following the steps described at “Add Eskills Service” section.
  2. Call the following code:
eskillsService.GetRoomInfo(sesion, room => Debug.Log("EskillsService: " + room.roomId), error => Debug.Log("EskillsService: " + error.Message));

This code will print the room ID or an error message.

"GetRoomInfo" method has 3 arguments:

  • session: session token you get from Join Match section step 6
  • success: a listener to get the successful response callback
  • error: a listener to get the error response callback

Set User Score

User’s score should be updated regularly. To do so, follow the next steps:

  1. Add Eskills prefab to the scene if needed following the steps described at “Add Eskills Service” section.
  2. Call the following code
eskillsService.SetScore(sesion, SetScoreBody.Status.COMPLETED, 100, room => Debug.Log("EskillsService: " + room.roomId), error => Debug.Log("EskillsService: " + error.Message));

This call will update the user’s score in eskills platform and print the room ID if successful or print an error message otherwise.

  • SetScore method has 5 arguments:
  • session: session token you get from Join Match section step 6
  • status: User status. There is 2 possibilities:
    • PLAYING: when the user is still playing and his score can change
    • COMPLETED: when the user finished the game. All SetScore call will fail after completing the match
  • score: the user’s current score
  • success: a listener to get the successful response callback
  • error: a listener to get the error response callback

Wait for all players to finish

Once the player finishes the game, you can wait for others to finish the game by calling GetRoomInfo function and check room status, once it is “COMPLETED” a winner has been declared and all the revenue share did take place.

Set user Name

To send the user name automatically when joining a match, you need to extend the class UserNameProvider and override the GetUserName method. Then you should attach it to your view and provide your view to Eskills prefab.
Here is an example of a class that extends UserNameProvider, grabs the user name from a text unity view and provides it back to Eskills: https://github.com/Catappult/eskills-unity-plugin/blob/master/Assets/Scripts/Eskills/Ui/TextUserNameProvider.cs

620

📘

Set user Name step not needed to perform when no StartPurchase method is called

When importing eskills prefab to your scene, it's only important to set the UserNameProvider from Eskills Prefab if you will use StartPurchase method from EskillsService script. If you don't need to use it, you only need to perform this step to import it.