Skip to content

Step-by-step integration

1. Basic Integration (Platform) [30 minutes]

  1. Create an account at Balancy.
  2. Once you see the dashboard, create a new game or use our Template (Recommended).

    Screenshot

  3. If you created a new game, install LiveOps package.

    Screenshot

  4. (Optional) Create a new template GameItem to describe your game item's qualities.

  5. Import your game Items using our GoogleSheets Synchronisation or add items manually.
  6. Deploy

    Screenshot

2. Basic Integration (Game) [10 minutes]

  1. Download the latest version of the plugin.
  2. Import the Balancy plugin in Unity project.
  3. When the compilation is complete, open Tools ► Balancy ► Config and authorise with the same login/password you used in the Balancy platform.

    Screenshot

  4. Select the game you need and click on Generate Code.

    Screenshot

  5. Init Balancy using the following code:

    Balancy.Main.Init(new Balancy.AppConfig {
        ApiGameId = YOUR_GAME_ID,
        PublicKey = YOUR_PUBLIC_KEY,
        Environment = Balancy.Constants.Environment.Development,
        OnReadyCallback = responseData => { Debug.Log("Balancy Initialized: " + responseData.Success); }
    });
    

    You can find YOUR_GAME_ID and YOUR_PUBLIC_KEY in the Balancy dashboard: Screenshot

  6. In the OnReadyCallback print all the Items your game has. You can read about the access to all the data here.

Balancy.Main.Init(new Balancy.AppConfig {
    ApiGameId = YOUR_GAME_ID,
    PublicKey = YOUR_PUBLIC_KEY,
    Environment = Balancy.Constants.Environment.Development,
    OnReadyCallback = responseData => { 
        Debug.Log("Balancy Initialized: " + responseData.Success);

        var defaultItems = DataManager.SmartObjects.Items; //<- use it if you store your items in our default Items section 
        var customItems = DataEditor.GameItems; //<- use it if created a custom GameItem

        var allItems = defaultItems; //I'll assume we use default items
        Debug.Log($"Total items count = {allItems.Count}");

        foreach (var item in allItems)
            Debug.Log($"{item.Name} : {item.MaxStack}");
    }
});

3. LiveOps Integration (Platform) [30 minutes]

  1. Create GameOffers

    Screenshot

  2. Create a Simple Script, which only activates an offer after 5 seconds. In the Activate Offer node, pick one of the Game Offers you created before.

    Screenshot Screenshot

  3. Create a Test Game Event and attach the Simple Script to it. Leaving Condition field empty means the event will be launched as soon as a player launches the game.

    Screenshot

  4. Deploy

4. LiveOps Integration (Game) [30 minutes]

  1. Create a new class SmartObjectsEventsExample and inherit it from our interface Balancy.SmartObjects.ISmartObjectsEvents, define all the interface methods. Or you can use the class, which comes with the package. You can find more information here.
  2. Make sure to write some text in the console for the following methods of the SmartObjectsEventsExample class:

    public void OnNewEventActivated(EventInfo eventInfo)
    {
        Debug.Log("=> OnNewEventActivated: " + eventInfo?.GameEvent?.Name);
    }
    
    public void OnNewOfferActivated(OfferInfo offerInfo)
    {
        Debug.Log("=> OnNewOfferActivated: " + offerInfo?.GameOffer?.Name + " ; Price = " + offerInfo?.PriceUSD + " ; Discount = " + offerInfo?.Discount);
    }
    
  3. Press Play in the Unity Editor.

  4. You should see the following logs in the console:
    1. "Balancy Initialized:..."
    2. "=> OnNewEventActivated:..."
    3. "=> OnNewOfferActivated:..." in 5 seconds

Congratulations. You have successfully completed LiveOps integration. Now can experiment with the platform and keep reading the documentation to learn more about its capabilities.