using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CategorySelection : MonoBehaviour { [SerializeField] Text CategoryNameText; [SerializeField] Toggle selectionToggle; private int questionCount; private Boolean selected; public int QuestionCount { get => questionCount; set => questionCount = value; } public bool Selected { get => selected; set => selected = value; } // Start is called before the first frame update void Start() { selectionToggle.onValueChanged.AddListener(SelectionChanged); } private void SelectionChanged(bool arg0) { Selected = arg0; } // Update is called once per frame void Update() { } internal void SetCategoryText(string categoryName, int questionCount) { CategoryNameText.text = categoryName + " (" + questionCount + ")"; } internal void SetSelected(bool selected) { selectionToggle.SetIsOnWithoutNotify(selected); } public string GetCategoryName() { string catText = CategoryNameText.text; return catText.Substring(0, catText.IndexOf('(') - 1); } public bool IsSelected() { return selectionToggle.isOn; } }