| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class CategorySelection : MonoBehaviour {
- [SerializeField] readonly Text CategoryNameText;
- [SerializeField] readonly 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;
- }
- }
|