Evelyn GameDev Logo
Published on

Set up a cloud backend for your game (Pretty useful for free!) (PlayFab / Unity)

Authors
  • avatar
    Evelyn
Set up a cloud backend for your game (Pretty useful for free!) (PlayFab / Unity)

Please share this article if you like!

icon of Evelyn
I'd like to easily implement ranking and push notification functions in my games.

If you're reading this article now, I'm sure you have such thoughts. In this article, I'd like to show you how to set up PlayFab first, in order to implement the functions that require such a server.

I recommend you use PlayFab. I implemented a ranking function in a game I developed, and it was very easy and free to implement.

PlayFab website

PlayFab is a cloud backend service operated by Microsoft, and is characterized by its very wide range of free applications.

Why do I recommend PlayFab?
  • You can implement functions that require a backend without having to prepare your own server.
  • Free up to 100,000 MAU
  • It has been used in Minecraft and many other applications.

There is also a video explaining the process, if you want to watch it.


Table of Contents

Importing the SDK

Let's go ahead and import the PlayFab SDK into any Unity project. Please visit the download link from the following URL. Then download the two SDKs circled by the red line.

PlayFab SDK for Unity
PlayFab website
PlayFab SDK for Unity

Once the download is complete, drag and drop the package into the Unity editor to complete importing the package.

Importing the SDK

Setting Up Your Project

Once the SDK has been imported, we'll prepare it for use in our Unity project by opening the PlayFav editor extension.

PlayFab Editor Extensions

If you already have a PlayFab account, please login. If you don't, we'll proceed as if you were creating an account.

Request an editor extension and create a new account.

Click on the icon to the right of the Editor Extension logo display to go to the PlayFab website, and enter the e-mail address and password you just created to log in. The first time you log in, you will be asked to verify your e-mail address, so make sure you do.

PlayFab's login screen

Create a new PlayFab title. It is best to use the same name as your game for clarity.

Title Management Screen

Go back to the Unity editor and select STUDIO and the title you just created.

Selecting a Studio and Title

Test the connection to the server.

Now that the setup is complete, let's create a test code for verification. We will create a script and edit it in Visual Studio.

Creating a Script

We will implement a simple login to make sure the tuna is properly teched to the server. The code looks like the following.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayFab;
using PlayFab.ClientModels;

public class TestPlayFab : MonoBehaviour
{
  void Start()
  {
    PlayFabClientAPI.LoginWithCustomID(
      new LoginWithCustomIDRequest { CustomId = "testuser", CreateAccount = true },
      result => Debug.Log("login success!!"),
      error => Debug.Log($"login failed: {error}")
    );
  }
}

Attach the script you have created to a game object and run it.

Attaching a script

A successful login text will appear in the console, confirming that the player has been added to the PlayFab management screen.

![Execution result]](/static/images/blog/playfab-setup/playfab-setup-10.jpeg)

What did you think of this article? Did you successfully complete the setup? I hope you'll read the Evelyn GameDev Blog, where I'll be showing you how to use PlayFab to implement the ranking function and push notifications.

Summary of this article

Let's set up PlayFab and get ready to implement various functions.

Please share this article if you like!