The creator-centric platform for building live games in Unity

Easily add social, commerce, and content management features to your live game with low-code, drag-and-drop prefabs fully integrated with your Unity workflow.

Distributing a Microservice

Overview

The purpose of this guide is for game makers to distribute server-authoritative C# functionality via Beamable Microservices.

Distribution

  • Game makers can distribute the Microservice internally within their organization and share it across several game projects
  • Or distribute the Microservice publicly for use by the community

Game Maker User Experience

During development, the game maker's user experience is as follows. There are 3 major parts to the process.

Steps

Follow these steps to get started.

Step 1. Setup Microservice

Name

Detail

  1. Setup Docker
  2. Create Microservice
  3. Call Microservice

• See Adding Microservices for more info

Note: Ensure that Microservice development is complete before continuing

Step 2. Package Microservice

Work within the same project created in Step 1 above.

Name

Detail

  1. Open the Source Unity project

Note: This Unity project will be the source of the Unity custom package

  1. Create the Unity custom package

• See Unity's docs.unity3d.com/Manual/CustomPackages.html for more info

  1. Host the Unity custom package

• Ex. Github.com

  1. Distribute the Unity custom package

• See Unity's Docs.unity3d.com/Manual/cus-share.html for more info

Note: There are several options. For this example, Beamable uses the Via Git URL solution

Step 3. Import Microservice

Name

Detail

  1. Open the Destination Unity project

Note: This Unity project will be the destination, where the Unity custom package will be used

  1. Import the Unity custom package
• See Unity's docs.unity3d.com/Manual/upm-ui-giturl.html for more info
*Note: There are several options. For this example, Beamable uses the `Via Git URL` solution with a url of `https://github.com/beamable/Microservices-TimedRewards.git`*

Example

Here are examples which cover common programming needs.

📘

Beamable SDK Examples

Source Unity Project - Github.com/beamable/Microservices-TimedRewards
Destination Unity Project - Github.com/beamable/Beamable_Microservices_Examples

Source - Microservices TimedRewards

This demonstrates;

  • How to create a Unity custom package as a Microservice
  • And its a production-ready Microservice which adds a "Timed Rewards" feature

Destination - Beamable Microservices Examples

This demonstrates;

  • How to import a Unity custom package as a Microservice
  • And its an example usage of the "Timed Rewards" feature

Code
Here are examples which cover common programming needs.

The TimedRewardsMicroserviceExample.cs demonstrates the custom code added to the destination project to properly consume the imported source project.

using UnityEngine;
using Beamable.Server.Clients;

namespace Beamable.Examples.Features.Microservices.TimedRewardsMicroserviceExample
{
    /// <summary>
    /// Demonstrates <see cref="Microservices"/>.
    /// </summary>
    public class TimedRewardsMicroserviceExample : MonoBehaviour
    {
        //  Properties  -----------------------------------
        
        //  Fields  ---------------------------------------
        [SerializeField] 
        private TimeRewardRef _timeRewardRef = null;
        
        private TimedRewardServiceClient  _timedRewardServiceClient;
        
        //  Unity Methods  --------------------------------

        protected void Start()
        {
            Debug.Log("Start() Instructions...\n" + 
            "* Complete docker setup per https://docs.beamable.com/docs/microservices-feature\n" +
            "* Start the server per https://docs.beamable.com/docs/microservices-feature\n" +
            "* Play This Scene\n" + 
            "* Enjoy!\n\n\n");
            
            SetupBeamable();
        }
        
        //  Methods  --------------------------------------
        private async void SetupBeamable()
        {
            var beamableAPI = await Beamable.API.Instance;

            Debug.Log($"beamableAPI.User.id = {beamableAPI.User.id}");
            
            _timedRewardServiceClient = new TimedRewardServiceClient();
            
            // #1 - Call Microservice
            bool isSuccess = await _timedRewardServiceClient.Claim(_timeRewardRef);
                
            // #2 - Result = true
            Debug.Log ($"AddMyValues() isSuccess = {isSuccess}");
        }
    }
}

Advanced

This section contains any advanced configuration options and workflows.

Updated 2 months ago


Distributing a Microservice


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.