SCILLBattlePass
public class SCILLBattlePass : SCILLThreadSafety
Overview
Add this component to a Unity GameObject. It will create a UI for the SelectedBattlePass
of the SCILLBattlePassManager. SCILLBattlePass
connects to these delegates of SCILLBattlePassManager to get notifications whenever the battle pass changes and updates UI accordingly:
The SCILLBattlePass
will only handle battle pass related UI, like unlocking/purchase buttons and will handle pagination
of the the levels. SCILLBattlePassLevels is responsible to render the levels
of the battle pass.
The best way to get started is to drop the BattlePass prefab into a Canvas. This prefab already has prepared the connections and hierarchy for a battle pass.
Inspector properties
unlockGroup
public GameObject unlockGroup;
Battle passes need to be unlocked, either by script or user interaction. Often Battle passes need to be purchased by users. Create the UI (purchase button, description, etc) for unlocking the battle pass within one container GameObject and connect it on this property. This script will hide the GameObject if the battle pass has already been unlocked and will show it, if the battle pass needs to be unlocked for the user.
currentLevel
public Text currentLevel;
A UnityEngine.UI.Text
field that will be set with the current active level. Just a number like 2 or 99.
imageXS
public Image imageXS;
You can set an image name in the Admin Panel for the battle pass. The script will try to load a sprite at runtime with the
image_xs
name of BattlePass. Please make sure that the sprite is in
a Resources
folder within the Unity Assets
folder!
imageS
public Image imageS;
You can set an image name in the Admin Panel for the battle pass. The script will try to load a sprite at runtime with the
image_s
name of BattlePass. Please make sure that the sprite is in
a Resources
folder within the Unity Assets
folder!
imageM
public Image imageM;
You can set an image name in the Admin Panel for the battle pass. The script will try to load a sprite at runtime with the
image_m
name of BattlePass. Please make sure that the sprite is in
a Resources
folder within the Unity Assets
folder!
imageL
public Image imageL;
You can set an image name in the Admin Panel for the battle pass. The script will try to load a sprite at runtime with the
image_l
name of BattlePass. Please make sure that the sprite is in
a Resources
folder within the Unity Assets
folder!
imageXL
public Image imageXL;
You can set an image name in the Admin Panel for the battle pass. The script will try to load a sprite at runtime with the
image_xl
name of BattlePass. Please make sure that the sprite is in
a Resources
folder within the Unity Assets
folder!
battlePassNameText
public Text battlePassNameText;
A UnityEngine.UI.Text
field which is used to render the battle pass name. The battle_pass_name
of BattlePass will be used.
Delegates
SCILLBattlePass
exposes a couple of delegates which allow other parts of the application to get “notified” whenever
something happens with the battle pass UI. For example if the battle pass is unlocked.
OnBattlePassUnlocked
If the battle pass is unlocked, the delegates will be called. This will allow you to update your UI once the battle pass has been unlocked.
public static event BattlePassUnlockedAction OnBattlePassUnlocked;
Definition
public delegate void BattlePassUnlockedAction(BattlePass battlePass);
Example
public class ExampleScript : MonoBehaviour
private void Awake()
{
SCILLBattlePass.OnBattlePassUnlocked += OnOnBattlePassUnlocked;
}
private void OnOnBattlePassUnlocked(BattlePass battlePass)
{
// If the battle pass was unlocked, then reload the levels and challenges
if (battlePass.battle_pass_id == SelectedBattlePass.battle_pass_id)
{
UpdateBattlePassLevelsFromServer();
}
}
}
Methods
OnBattlePassUnlockButtonPressed
public async void OnBattlePassUnlockButtonPressed()
Connect a buttons click event to this function. It will unlock the battle pass. However, if you want to add In-App purchase
you will need to implement yourself and then use the UnlockBattlePass
function of the SCILL SDK.
// Use this payload to send some info about the purchase. We use that (later) for planned Game/Business Analysis features
// in the Admin Panel.
var purchaseInfo = new BattlePassUnlockPayload(0, "EUR");
// Unlock the battle pass
var unlockInfo = await SCILLManager.Instance.SCILLClient.UnlockBattlePassAsync(battlePass.battle_pass_id, purchaseInfo);
if (unlockInfo != null)
{
// If a battle pass is unlocked you will get the battle pass object back as a response. Here we just set the
// unlocked_at property as this indicates the UI to show the unlock button or not.
battlePass.unlocked_at = unlockInfo.purchased_at;
OnBattlePassUnlocked?.Invoke(battlePass);
UpdateUI();
}