SCILLChallengeItem
class SCILLChallengeItem : MonoBehaviour
Overview
This class implements user interface for a personal challenge. Attach it to a game object and connect properties with
user interface elements. You need to create a prefab and connect to the challengePrefab
in the SCILLPersonalChallenges component.
Inspector Properties
challengeName
public Text challengeName;
Connect a UnityEngine.UI.Text
component which will be set with the challenge_name
of the Challenge object.
challengeImage
public Image challengeImage;
The Challenge has a challenge_icon
setting. This is a string value that
you can set in the Admin Panel. The class will try to load a sprite with the same name from your Asset database and will
set that as the sprite of the connected UnityEngine.UI.Image
class.
Please note: The sprite is loaded at runtime and must be within a Resources
folder in your Asset database so that Unity
exposes that asset so that it can be loaded dynamically.
challengeProgressSlider
public Slider challengeProgressSlider;
The challenge progress will be set in this UnityEngine.UI.Slider
component that you can connect to this property.
Remove the handle from the slider as this is not required.
challengeName
public Text challengeGoal;
Connect a UnityEngine.UI.Text
component which will be set with the challenge_name
of the Challenge object.
challengeProgress
public RectTransform challengeProgress;
Connect a 2D Transform that will host the challengeProgressSlider
. It will be set inactive if the challenge is not
active to hide the progress bar and will be set to active otherwise.
timeRemaining
public Text timeRemaining;
Connect a UnityEngine.UI.Text
component which will be used to set the remaining time of the challenge. Per default this
will default to this format: mm:hh:ss
.
actions
public RectTransform actions;
Challenges require a couple of user actions - typically implemented with buttons. All those buttons can be grouped in this transform which will be set to inactive if there are no user interactions allowed with this challenge.
unlockButton
public Button unlockButton;
A UnityEngine.UI.Button
component that you connected to the OnUnlockButtonPressed function. It will be visible if
the challenge can be unlocked, otherwise it will be hidden.
activateButton
public Button activateButton;
A UnityEngine.UI.Button
component that you connected to the OnActivateButtonPressed
function. It will be visible if
the challenge can be unlocked, otherwise it will be hidden.
claimButton
public Button claimButton;
A UnityEngine.UI.Button
component that you connected to the OnClaimButtonPressed function. It will be visible if
the challenge can be unlocked, otherwise it will be hidden.
cancelButton
public Button cancelButton;
A UnityEngine.UI.Button
component that you connected to the OnCancelButtonPressed function. It will be visible if
the challenge can be unlocked, otherwise it will be hidden.
Methods
OnUnlockButtonPressed
public void OnUnlockButtonPressed()
Connect this function to the unlock buttons click event. It will unlock the challenge using the SCILLClient.UnlockPersonalChallenge method.
OnActivateButtonPressed
public void OnActivateButtonPressed()
Connect this function to the unlock buttons click event. It will unlock the challenge using the SCILLClient.ActivatePersonalChallenge method.
OnClaimButtonPressed
public void OnClaimButtonPressed()
Connect this function to the unlock buttons click event. It will unlock the challenge using the SCILLClient.ClaimPersonalChallengeReward method.
OnCancelButtonPressed
public void OnCancelButtonPressed()
Connect this function to the unlock buttons click event. It will unlock the challenge using the SCILLClient.CancelPersonalChallenge method.