selectCategoriesPanelController.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class selectCategoriesPanelController : MonoBehaviour
  6. {
  7. [SerializeField] Button OpenDialogButton;
  8. [SerializeField] GameObject SelectCategoriesDialog;
  9. [SerializeField] Text SelectCategoriesText;
  10. private int selectedQuestionCount;
  11. private SelectCategoryScript selectCategoryScript;
  12. public int SelectedQuestionCount { get => selectedQuestionCount; set => selectedQuestionCount = value; }
  13. // Start is called before the first frame update
  14. void Start()
  15. {
  16. OpenDialogButton.onClick.AddListener(ShowDialog);
  17. selectCategoryScript = SelectCategoriesDialog.GetComponent<SelectCategoryScript>();
  18. SelectCategoriesText.text = string.Format(LocalizationManager.Instance.GetText("SELECT_CATEGORIES_TEXT_ALL"),
  19. LocalizationManager.Instance.GetText("ALL"));
  20. }
  21. // Update is called once per frame
  22. void Update()
  23. {
  24. if (SelectCategoriesText.text.Contains("{")) {
  25. SelectCategoriesText.text = string.Format(LocalizationManager.Instance.GetText("SELECT_CATEGORIES_TEXT_ALL"),
  26. LocalizationManager.Instance.GetText("ALL"));
  27. }
  28. }
  29. public void UpdateCategoryText(int questionCount) {
  30. SelectCategoriesText.text = string.Format(LocalizationManager.Instance.GetText("SELECT_CATEGORIES_TEXT"),
  31. selectCategoryScript.GetCategoriesSelectedCount(),
  32. questionCount);
  33. SelectedQuestionCount = questionCount;
  34. }
  35. internal void ShowDialog() {
  36. SelectCategoriesDialog.SetActive(true);
  37. }
  38. public List<CategoryPanel.Category> GetSelectedCategories() {
  39. List<CategoryPanel.Category> selectedCategories = selectCategoryScript.GetSelectedCategories();
  40. return selectedCategories;
  41. }
  42. }