Adding a Game
To use the SDK features:
- Add the game in the game control panel
- Press the
Add game
- Going to the new window give the name to the game and click the
Add game
again - After that you will get into the interface of the game control panel
Code installing
To embed SDK in the game:
- JavaScript
- Construct 3
- Unity
- Add the script in
index.html
- Indicate
projectId
andpublicToken
. They must correspond to theID of the project
andpublic key
from the game control panel:
index.html
// install code before body close tag
<script async src="https://gamepush.com/sdk/game-score.js?projectId=2782&publicToken=xT3RpsJMXpKWHPrTWkv3VBeHJKvCBccT&callback=onGPInit"></script>
<script>
window.onGPInit = (gp) => {
// ready
};
</script>
Follow this instructions: How to install GamePush plugin in Construct 3.
- Import into the Unity project .unitypackage. The plugin works on the versions of the Unity 2020 and above
- Add the plugin in the standard way:
Assets - Import package - Custom Package
- Open the Gamescore folder and move the Prefab Gamescoresdk to the project hierarchy - Hierarchy
- To create assembly, select the WebGL Gamescore Template:
Edit - Preferences - Player - Resolution and Presentation
. IndicateProject ID
andtoken
. They must correspond to theID of the project
andpublic key
from the game control panel:
info
See Tutorial Adding plugin to a Unity Project
SDK initialization
- JavaScript
- Construct 3
- Unity
After initializing the SDK, the onGPInit
function will be called, in which a ready-to-use SDK instance with all managers will be passed as an argument. For correct interaction with the player, you need to wait synchronizing the player with the server.
index.html
// Add GS script url
<script async src="https://gamepush.com/sdk/game-score.js?projectId=4&publicToken=xT3RpsJMXpKWHPrTWkv3VBeHJKvCBccT&callback=onGPInit"></script>
<script>
window.onGPInit = async (gp) => {
// Wait while the player syncs with the server
await gp.player.ready;
// Show the ad preloader and wait until it ends
await gp.ads.showPreloader();
// Show the sticky banner (then it will update itself)
gp.ads.showSticky();
// You can start the game :)
};
</script>
SDK initializes automatically.
- Create C# Script Init.cs
- In the script you need to connect the GameScore library
using GameScore
and subscribe to the eventGS_SDK.OnReady
:
using UnityEngine;
// Add the libraryGameScore
using GameScore;
public class Init : MonoBehaviour
{
// Subscribe to the eventGS_SDK.OnReady;
private void OnEnable()
{
GS_SDK.OnReady += OnSDKReady;
}
private void OnDisable()
{
GS_SDK.OnReady -= OnSDKReady;
}
private void OnSDKReady()
{
// From this moment, the SDK is ready and you can call all the plugin methods
}
}
- С этого момента SDK готов и можно вызывать все методы плагина
Stay in Touch
Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.
GamePush Community Telegram
: @gs_community.
For your suggestions e-mail
: [email protected]
We Wish you Success!