Home | Portfolio | Resume | About

EAFU

EAFU Screenshot

Overview

After working in backend and game services, I knew there was a need for easy upkeep for game developers. So, I created an open-source lightweight API for Unity to access backend services with minimal setup. Specifically made for Azure Functions, the API can be used for other services, like AWS with a few header changes. I created a sample Unity project to help others understand how it works.

Eafu Example

Key Features

Implementation

Implementing EAFU in a Unity project involves a few steps:

  1. Set Up Azure Functions: Ensure that your backend is ready to receive and respond to requests from Unity.
  2. Configure URLs and Keys: Depending on your development stage, you might use Unity Remote Config for production or a local.settings.json file for local development.
  3. Create Custom APIs: Inherit from the EAFUApi class and define your endpoints.
  4. Initialize and Use Your APIs: Set up your API URLs in Unity and start making requests to your Azure Functions.

Game API Example

The GameApi class, built using the Easy Azure Functions for Unity (EAFU) library, simplifies interactions with backend services. It provides methods like CreatePlayer to send player data and GetLeaderboard to fetch leaderboard data from Azure Functions.

[Serializable] public class GameApi : EAFUApi { public Player player { get; set; }

public void CreatePlayer(string name, int score, int gameDuration, Action PostPlayerAction) { player = new Player(name, score, gameDuration); Post(player, PostPlayerAction); }

public void GetLeaderboard(Action<List> GetLeaderboardsAction) => Get(GetLeaderboardsAction); }

You can use an instance of GameApi to create a player and update the leaderboard in two action callbacks:

// Post Player subscribte GetLeaderboards after creating Player gameApi.CreatePlayer(playerName, score, gameDuration, postPlayerAction => { // Get Leaderboards and Set Game UI gameApi.GetLeaderboard(SetLeaderboard)); }

Check out the project on Github

Technologies Used

  • C#
  • Unity
  • Azure Functions