SCILLCategoryItem
class SCILLCategoryItem : MonoBehaviour
Overview
Challenges are grouped into categories. Attach this script to a prefab that you set as the categoryPrefab
in the
SCILLPersonalChallenges component. Categories instantiate challengePrefab
objects that are either set directly in this class or it’s taken from the parent SCILLPersonalChallenges component.
Category UI support expanding and collapsing the UI. Use the expanded
setting to set the expansion state at start.
Inspector Properties
challengePrefab
public SCILLChallengeItem challengePrefab;
The prefab used for instantiating SCILLChallengeItem instances. If you leave this blank, the challengePrefab
setting of the parent SCILLPersonalChallenges will be used instead.
expanded
public bool expanded = true;
Categories can be collapsed. With this setting you can set the default state of this category. Per default it will be expanded.
categoryName
public Text categoryName;
A UnityEngine.UI.Text
component that will be used to set the categories name
challengesContainer
public Transform challengesContainer;
Challenges instantiated will be added as children into this transform if set, otherwise it will be directly added as child to this game object.
Methods
OnToggleExpanded
public void OnToggleExpanded()
Connect a click event of a toggle button to this function to hide all children of this category object (or the
challengeContainer
) if expanded
is false
, otherwise show them.
UpdateChallengeList
public void UpdateChallengeList()
Call this function to update the UI if data have been changing. The SCILLPersonalChallenges always calls this function once data has been changed, either because of user interactions or incoming real time update messages.
UpdateChallenge
public void UpdateChallenge(Challenge challenge)
Call this function to update an individual challenge in the categories challenges list.