CategorySelection.cs 954 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class CategorySelection : MonoBehaviour
  6. {
  7. [SerializeField] Text CategoryNameText;
  8. [SerializeField] Toggle selectionToggle;
  9. // Start is called before the first frame update
  10. void Start()
  11. {
  12. }
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. }
  17. internal void SetCategoryText(string categoryName, int questionCount) {
  18. CategoryNameText.text = categoryName + " (" + questionCount + ")";
  19. }
  20. internal void SetSelected(bool selected) {
  21. selectionToggle.SetIsOnWithoutNotify(selected);
  22. }
  23. public string getCategoryName() {
  24. string catText = CategoryNameText.text;
  25. return catText.Substring(0, catText.IndexOf('(') - 1);
  26. }
  27. public bool isSelected() {
  28. return selectionToggle.isOn;
  29. }
  30. }