Configuration guide

This page describes setting up project to get ready for platform usage.

Note
Make sure you have read carefully information provided on General overview page and only then proceed further with any of next sections of integration guide.
This guide is based on experience of successful integration of various games with Platform.
Warning
Follow the described steps and tips of the documentation attentively and methodically to prevent any troubleshooting during the integration process.

To successfully integrate with EazeGamesSDK, you will be provided with the configuration file EAZConfig.plist. This file will contain the mandatory information for the Game Owner, such as Game Owner ID and Encryption Key for games. You will need to add this file to your application’s bundle. For Unity3D game you have to put the configuration file in the root of Assets folder: Assets/EAZConfig.plist During testing of the Game, this configuration file will be valid only for sandbox environment. Prior first release, please contact our support team, so that they will duplicate settings from sandbox environment to production environment, so there will be no need to change anything in EAZConfig.plist file. After you have successfully added the configuration file, it is time to configure the EazeGamesSDK inside the project.

Installation guide

To use EazeGamesSDK in your Unity3D project you will need EazeGamesUnityPlugin.unitypackage and EazeGamesSDK.framework. To download latest EazeGamesUnityPlugin follow this link .

Note
EazeGamesUnityPlugin contains two static libraries libEAZUnityManager.a and libEAZUnityManagerSimulator.a. Before building project for AppStore, remove library for Simulator from Xcode project. If you experience some conflicts with *.dll in Unity3D or there are some missing components please check if /UNITY-IPHONE/EazeGamesSDK.dll is set to iOS platform only and /UNITY-DUMMY/EazeGamesSDK.dll is set to all platforms not including iOS. In Assets/EazeGamesSDK/Resources/EazeGamesSettings.asset, there are two options: DEBUG_MODE (will enable messages from plugin side in console) and Environment, which is represented by EazeGamesEnvironment enum. There you have to select proper environment before building Xcode project.
Use sandbox environment for testing, or production environment for release.

Carthage configuration

To be able to install EazeGamesSDK.framework using Carthage dependency manager follow these steps:

  1. Installing Carthage (can skip if you have Carthage installed )
  2. Set up SDK version ( also you can find how to use Carthage here ):
    Open Cartfile (Assets/Editor/Carthage/) and paste following based on your Xcode version, specify supported version of SDK with ~> or == :
    • for Xcode 11.0:
      binary "https://s3.eu-central-1.amazonaws.com/whitelabel.sdk/eazegames/Xcode11.0/EazeGamesSDK.json" ~> 2.0.6
    • for Xcode 11.1:
      binary "https://s3.eu-central-1.amazonaws.com/whitelabel.sdk/eazegames/Xcode11.1/EazeGamesSDK.json" ~> 2.0.6
    • for Xcode 11.2:
      binary "https://s3.eu-central-1.amazonaws.com/whitelabel.sdk/eazegames/Xcode11.2/EazeGamesSDK.json" ~> 2.0.6
    • for Xcode 11.2.1:
      binary "https://s3.eu-central-1.amazonaws.com/whitelabel.sdk/eazegames/Xcode11.2.1/EazeGamesSDK.json" ~> 2.0.6
    • for Xcode 11.3:
      binary "https://s3.eu-central-1.amazonaws.com/whitelabel.sdk/eazegames/Xcode11.3/EazeGamesSDK.json" ~> 2.0.6
      Note
      The SDK is distributed as compiled binary and since swift language doesn’t have Module Stability, it is necessary to build separate binary for each Xcode version. Therefore it is necessary to select SDK binary based on your Xcode version, you can achieve this by using path pattern for the binary link:
  3. Pattern for the binary link is simple:
    binary “https://s3.eu-central-1.amazonaws.com/whitelabel.sdk/eazegames/Xcode + { Xcode version } + /EazeGamesSDK.json” + { ~> or == } + 2.0.6.
  4. Save Cartfile.

Unity project setup

  1. Switch project platform in File/Build Settings to IOS and in Player Settings/IOS/Other settings/Target minimum IOS version define target IOS version for your application.
    Note
    Minimum supported iOS version : 11.4
  2. In order to be able to build Xcode project for IOS and have connection with EazeGames server first of all add your EAZConfig.plist and GoogleService-Info.plist(to use Firebase push notifications functionality) files provided by EazeGames team to /Assets folder of your Unity project.
  3. Configure scenes run sequence. Suggested Scenes in Build hierarchy
    • Initialization scene. Scene that will run first on application launch that contains DontDestroyOnLoad GameManager object with functional GamePreparationManager script of triggering and catching game preperation events of SDK.
    • Gameplay scenes.
      Every gameplay scene should preferably contain component GamePlayManager script with every UI object attached, that uses runtime variables like timer or score and trigger/catch gameplay events.
      • Multiple levels game: Levels scenes with similar names, preferably with level index in the end of name like Level1, Level2, etc for simpler level scene switching. (Levels can be generated on one gameplay scene if it is preferable, but levels with the same indexes must be identical on different devices. Gameplay experience must be the same for player and his opponent with no random game elements).
      • No level game: gameplay content(including GamePlayManager script) should be implemented on initialization scene.
    • Custom Loading screen scene to show when scene is loading(optional).
  4. Configure initialization scene GamePreparationManager script component, preferably dividing runtime gameplay from game preparation.
    Note
    For proper timer implementation, provided Class Epoch can be used. Examples of this class usage are written in GamePreparationManager and GamePlayManager scripts code snippets below.
    Epoch class code snippet:
    Epoch.cs
    using System;
    public static class Epoch
    {
    public static int Current()
    {
    DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
    int currentEpochTime = (int)(DateTime.UtcNow - epochStart).TotalSeconds;
    return currentEpochTime;
    }
    public static string GetTimerString(int timeLeft)
    {
    int minutes = timeLeft / 60;
    int seconds = timeLeft - (minutes * 60);
    string timer = (minutes<10?"0": "") + minutes + " : " + (seconds<10?"0": "") + seconds;
    return timer;
    }
    }
    Example code snippets for GameManager object script components:
    Warning
    Modules/Provided macros description section contains information about macros provided in these code snippets.
    Make sure, that macros and code snippets that aren't used are commented or erased.
    GamePreparationManager.cs
    #define FCM_PRESENT
    #define MULTIPLE_SCENES_LEVELS
    #define LOADING_SCENE
    using System.Collections.Generic;
    using System.Linq;
    using EazeGamesSDK;
    #if FCM_PRESENT
    using Firebase.Messaging;
    #endif
    using UnityEngine;
    using UnityEngine.SceneManagement;
    public class GamePreparationManager : MonoBehaviour, EAZGamePreparationDelegate, EAZGamePlayDelegate
    {
    public static event System.Action DidEndGameEvent;
    public static event System.Action WaitingForOpponentEvent;
    public static event System.Action<long> DidReceiveOpponentsScoreEvent;
    public static event System.Action<EAZGameStartInfo> DidReceiveStartGameInfo;
    public static List<int> levelList = new List<int>();
    public static int currentLevel = 0;
    public static long currentScore = 0;
    public static long oppScore = 0;
    public static bool playing = false;
    public static int endDate = 0;
    public static int gameDuration = 0;
    private void Awake()
    {
    PlayerPrefs.DeleteAll();
    if (instance == null)
    {
    instance = this;
    DontDestroyOnLoad(instance);
    #if FCM_PRESENT
    FirebaseMessaging.TokenReceived += OnTokenReceived;
    #endif
    #if MULTIPLE_SCENES_LEVELS
    SceneManager.sceneLoaded += OnSceneLoaded;
    #endif
    EazeGames.shared.gamePreparationManager.setPreparationDelegate(this);
    }
    else if (instance != this)
    //Prevents multiple API calls on Initial scene reload
    Destroy(gameObject);
    }
    #if MULTIPLE_SCENES_LEVELS
    private void OnSceneLoaded(Scene arg0, LoadSceneMode arg1)
    {
    #if LOADING_SCENE
    if (arg0.name == "{Loading scene name}")
    {
    SceneManager.LoadSceneAsync("Level" + levelList[currentLevel]);
    }
    #endif
    if (arg0.name == "Level" + levelList[0])
    {
    playing = true;
    }
    }
    #endif
    #region GamePreparationDelegate
    private void gameDidLoad()
    {
    EazeGames.shared.gamePreparationManager.gameDidLoad();
    }
    public void startLoadingGameResourcesFor(string gameId)
    {
    }
    EAZGameStartInfo startGameInfo)
    {
    gameDuration = startGameInfo.gameDuration;
    #if MULTIPLE_SCENES_LEVELS
    levelList = startGameInfo.levels.Split('-').Select(int.Parse).ToList();
    #endif
    EazeGames.shared.gamePlayManager.setGamePlayDelegate(this);
    #if MULTIPLE_SCENES_LEVELS
    #if LOADING_SCENE
    SceneManager.LoadScene("{Loading scene name}");
    #else
    SceneManager.LoadScene("Level" + levelList[currentLevel]);
    #endif
    #else
    playing = true;
    #endif
    }
    #endregion
    #region EAZGamePlayDelegate
    public void didEndGame()
    {
    if (DidEndGameEvent != null)
    {
    }
    }
    public void didReceiveOpponentsScore(long opponentScore)
    {
    oppScore = opponentScore;
    {
    }
    }
    public void waitingForOpponent()
    {
    {
    }
    }
    #endregion
    #region GamePlayEvents
    public void didStartPlaying()
    {
    EazeGames.shared.gamePlayManager.didStartPlaying();
    }
    //
    public void SendScore(long gameScore)
    {
    currentScore = gameScore;
    EazeGames.shared.gamePlayManager.sendScore(gameScore);
    }
    public void FinishGame(long finalScore)
    {
    EazeGames.shared.gamePlayManager.finishPlayingWithFinalScore(finalScore);
    }
    public void LeaveGame()
    {
    EazeGames.shared.gamePlayManager.leaveGame();
    }
    #endregion
    #region PushManagament
    #if FCM_PRESENT
    private static void OnTokenReceived( object sender, TokenReceivedEventArgs token )
    {
    EazeGames.shared.setFCMToken( token.Token );
    }
    #endif
    #endregion
    private void OnApplicationFocus(bool focus)
    {
    if (focus && SceneManager.GetActiveScene().name != "{InitSceneName}")
    {
    #if LOADING_SCENE
    SceneManager.LoadScene("{LoadingSceneName}");
    #else
    SceneManager.LoadScene("{InitSceneName}");
    #endif
    }
    }
    public static void EndGame(){
    oppScore = 0;
    playing = false;
    endDate = 0;
    }
    }
  5. Configure Gameplay scene(-s) script component, preferably separating runtime gameplay from game preparation:
    GamePlayManager.cs
    //#define MULTIPLE_SCENES_LEVELS
    //#define LOADING_SCENE
    using UnityEngine;
    using UnityEngine.SceneManagement;
    using UnityEngine.UI;
    public class GamePlayManager : MonoBehaviour
    {
    [SerializeField] Text OppScore;
    [SerializeField] Text Score;
    [SerializeField] Text timer;
    [SerializeField] Button leave;
    public void LeaveGame()
    {
    }
    public void OnEnable()
    {
    }
    void OnDisable()
    {
    }
    public void UpdateOpponentsScore(long opponentsScore)
    {
    /*Opponent's score text object*/OppScore.text = "Opponent : " + opponentsScore;
    }
    void UpdateScore(long score)
    {
    /*Player's score text object*/
    Score.text = "Score : " + score.ToString();
    if (score > 0)
    {
    //Send new player score to platform
    }
    }
    void Start()
    {
    leave.onClick.AddListener(LeaveGame);
    }
    }
    void Update()
    {
    if(timeLeft > 0)
    else
    }
    }
    bool gameEnded = false;
    #if MULTIPLE_SCENES_LEVELS
    void Switch()
    {
    if (!gameEnded)
    {
    #if LOADING_SCENE
    SceneManager.LoadScene("{Loading scene name}");
    #else
    #endif
    }
    }
    #endif
    void EndGame()
    {
    if (!gameEnded)
    {
    gameEnded = true;
    }
    }
    void Finish(long score)
    {
    }
    }

    Warning
    If you have more than one Xcode versions installed on your Mac, make sure your system uses Swift version that is supported by Xcode version used for building Xcode project (to check the version use command swift -v in Terminal). If not, execute
    sudo xcode-select -switch {path to needed Xcode app location}/{Needed Xcode version app name}.app
    in Terminal to set up as default the Xcode version you want to use for the build (and its supported swift version). Also if there is a folder 2.0.6 by path Users/{user}/Library(might be hidden)/Caches/org.carthage.CarthageKit/binaries/EazeGamesSDK, remove it before Xcode build.
  6. Build Unity project for IOS in order to create Xcode representation of application.
  7. On successful build run .xcodeproj project file in Build folder(.xcworkspace if using FireBaseSDK).

Xcode build project setup

  1. As was told earlier to successfully integrate with EazeGames SDK, you will be provided with the configuration file EAZConfig.plist. This file should be in the Copy Bundle Resources Build Phase of your Target.
    Config copy phase to Xcode project (is performed automatically).
  2. Go to application targets’ General Settings tab. Check if EazeGamesSDK.framework listed in Linked Frameworks and Libraries section:
  3. Go to application targets’ Build Phases tab and add new run script:
    • Script area: /usr/local/bin/carthage copy-frameworks
    • Input Files: $(SRCROOT)/Carthage/Build/iOS/EazeGamesSDK.framework
    • Output Files: $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/EazeGamesSDK.framework
  4. In application targets’ Build Settings check if Always Embed Swift Standard Libraries is set to Yes
  5. To fix application rotation to portrait, open /Classes/UnityAppController.mm in Xcode build folder and replace code under supportedInterfaceOrientationsForWindow method to
    return (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationPortraitUpsideDown);

Launch loading logo

After application’s launch and initialize of the EazeGames SDK, it requires time to load resources for the Landing Page. By default during this loading sequence, SDK will show a Default logo screen:

It is possible to customize the logo image, by adding an image asset with name gtz_launch_logo to your project’s asset catalog:



GamePlayManager.EndGame
void EndGame()
Definition: GamePlayManager.cs:130
GamePlayManager.leave
Button leave
Definition: GamePlayManager.cs:24
GamePreparationManager.OnTokenReceived
static void OnTokenReceived(object sender, TokenReceivedEventArgs token)
Definition: GamePreparationManager.cs:271
GamePreparationManager.OnSceneLoaded
void OnSceneLoaded(Scene arg0, LoadSceneMode arg1)
Definition: GamePreparationManager.cs:110
GamePlayManager.OnDisable
void OnDisable()
Definition: GamePlayManager.cs:45
GamePreparationManager.WaitingForOpponentEvent
static System.Action WaitingForOpponentEvent
Definition: GamePreparationManager.cs:39
GamePlayManager.UpdateOpponentsScore
void UpdateOpponentsScore(long opponentsScore)
Definition: GamePlayManager.cs:53
GamePreparationManager.gameDidLoad
void gameDidLoad()
Definition: GamePreparationManager.cs:133
EAZGameStartInfo
Definition: EAZGameStartInfo.cs:7
GamePreparationManager.SendScore
void SendScore(long gameScore)
Definition: GamePreparationManager.cs:243
GamePreparationManager.endDate
static int endDate
Definition: GamePreparationManager.cs:71
GamePlayManager.LeaveGame
void LeaveGame()
Definition: GamePlayManager.cs:29
GamePreparationManager.currentLevel
static int currentLevel
Definition: GamePreparationManager.cs:55
GamePreparationManager.FinishGame
void FinishGame(long finalScore)
Definition: GamePreparationManager.cs:253
GamePlayManager.OppScore
Text OppScore
Definition: GamePlayManager.cs:12
GamePlayManager.UpdateScore
void UpdateScore(long score)
Definition: GamePlayManager.cs:62
GamePreparationManager.EndGame
static void EndGame()
Definition: GamePreparationManager.cs:297
GamePreparationManager.DidReceiveStartGameInfo
static System.Action< EAZGameStartInfo > DidReceiveStartGameInfo
Definition: GamePreparationManager.cs:47
EAZGameStartInfo.levels
string levels
Definition: EAZGameStartInfo.cs:20
EAZGameStartInfo.gameDuration
int gameDuration
Definition: EAZGameStartInfo.cs:12
GamePreparationManager.didEndGame
void didEndGame()
Definition: GamePreparationManager.cs:196
GamePlayManager.timer
Text timer
Definition: GamePlayManager.cs:20
Epoch.GetTimerString
static string GetTimerString(int timeLeft)
Definition: Epoch.cs:19
GamePlayManager.Start
void Start()
Definition: GamePlayManager.cs:78
GamePlayManager.Update
void Update()
Definition: GamePlayManager.cs:90
GamePlayManager.OnEnable
void OnEnable()
Definition: GamePlayManager.cs:38
GamePreparationManager.instance
static GamePreparationManager instance
Definition: GamePreparationManager.cs:31
GamePreparationManager.oppScore
static long oppScore
Definition: GamePreparationManager.cs:63
GamePreparationManager
Definition: GamePreparationManager.cs:26
Epoch.Current
static int Current()
Definition: Epoch.cs:8
GamePreparationManager.gameDuration
static int gameDuration
Definition: GamePreparationManager.cs:75
GamePreparationManager.LeaveGame
void LeaveGame()
Definition: GamePreparationManager.cs:261
GamePreparationManager.playing
static bool playing
Definition: GamePreparationManager.cs:67
GamePlayManager
Definition: GamePlayManager.cs:7
GamePlayManager.gameEnded
bool gameEnded
Definition: GamePlayManager.cs:104
GamePreparationManager.DidReceiveOpponentsScoreEvent
static System.Action< long > DidReceiveOpponentsScoreEvent
Definition: GamePreparationManager.cs:43
EazeGames
Definition: EazeGames.cs:2
GamePreparationManager.startLoadingGameResourcesFor
void startLoadingGameResourcesFor(string gameId)
Definition: GamePreparationManager.cs:141
GamePreparationManager.provideGameControllerWithStartGameInfo
void provideGameControllerWithStartGameInfo(EAZGameStartInfo startGameInfo)
Definition: GamePreparationManager.cs:166
GamePlayManager.Score
Text Score
Definition: GamePlayManager.cs:16
GamePreparationManager.DidEndGameEvent
static System.Action DidEndGameEvent
Definition: GamePreparationManager.cs:35
Epoch
Definition: Epoch.cs:3
GamePlayManager.Finish
void Finish(long score)
Definition: GamePlayManager.cs:143
GamePreparationManager.didStartPlaying
void didStartPlaying()
Definition: GamePreparationManager.cs:233
GamePreparationManager.didReceiveOpponentsScore
void didReceiveOpponentsScore(long opponentScore)
Definition: GamePreparationManager.cs:208
GamePreparationManager.waitingForOpponent
void waitingForOpponent()
Definition: GamePreparationManager.cs:220
GamePreparationManager.levelList
static List< int > levelList
Definition: GamePreparationManager.cs:51
GamePreparationManager.Awake
void Awake()
Definition: GamePreparationManager.cs:86
GamePreparationManager.currentScore
static long currentScore
Definition: GamePreparationManager.cs:59