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:
- Installing Carthage (can skip if you have Carthage installed )
- 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:
- 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.
- Save Cartfile.
Unity project setup
- 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
- 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.
- 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).
- 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
{
{
DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
int currentEpochTime = (int)(DateTime.UtcNow - epochStart).TotalSeconds;
return currentEpochTime;
}
{
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 static List<int>
levelList =
new List<int>();
public static bool playing =
false;
{
PlayerPrefs.DeleteAll();
{
#if FCM_PRESENT
#endif
#if MULTIPLE_SCENES_LEVELS
#endif
EazeGames.shared.gamePreparationManager.setPreparationDelegate(
this);
}
Destroy(gameObject);
}
#if MULTIPLE_SCENES_LEVELS
{
#if LOADING_SCENE
if (arg0.name == "{Loading scene name}")
{
}
#endif
{
}
}
#endif
#region GamePreparationDelegate
{
EazeGames.shared.gamePreparationManager.gameDidLoad();
}
{
}
{
#if MULTIPLE_SCENES_LEVELS
#endif
EazeGames.shared.gamePlayManager.setGamePlayDelegate(
this);
#if MULTIPLE_SCENES_LEVELS
#if LOADING_SCENE
SceneManager.LoadScene("{Loading scene name}");
#else
#endif
#else
#endif
}
#endregion
#region EAZGamePlayDelegate
{
{
}
}
{
{
}
}
{
{
}
}
#endregion
#region GamePlayEvents
{
EazeGames.shared.gamePlayManager.didStartPlaying();
}
{
EazeGames.shared.gamePlayManager.sendScore(gameScore);
}
{
EazeGames.shared.gamePlayManager.finishPlayingWithFinalScore(finalScore);
}
{
EazeGames.shared.gamePlayManager.leaveGame();
}
#endregion
#region PushManagament
#if FCM_PRESENT
private static void OnTokenReceived(
object sender, TokenReceivedEventArgs 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
}
}
}
}
- Configure Gameplay scene(-s) script component, preferably separating runtime gameplay from game preparation:
GamePlayManager.cs
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
{
[SerializeField] Text
Score;
[SerializeField] Text
timer;
[SerializeField] Button
leave;
{
}
{
}
{
}
{
OppScore.text =
"Opponent : " + opponentsScore;
}
{
Score.text =
"Score : " + score.ToString();
if (score > 0)
{
}
}
{
}
}
{
if(timeLeft > 0)
else
}
}
#if MULTIPLE_SCENES_LEVELS
void Switch()
{
{
#if LOADING_SCENE
SceneManager.LoadScene("{Loading scene name}");
#else
#endif
}
}
#endif
{
{
}
}
{
}
}
- 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.
- Build Unity project for IOS in order to create Xcode representation of application.
- On successful build run .xcodeproj project file in Build folder(.xcworkspace if using FireBaseSDK).
Xcode build project setup
- 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).
- Go to application targets’ General Settings tab. Check if EazeGamesSDK.framework listed in Linked Frameworks and Libraries section:
- 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
- In application targets’ Build Settings check if Always Embed Swift Standard Libraries is set to Yes
- 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: