private void Start() { if (!GameManager.Instance.IsGameLoaded()) { GameManager.Instance.LoadGame(); } for (int i = 0; i < categories.Length; i++) { int index = i; CategoryCard card = Instantiate(categoryCardPrefab, categoriesParent.transform); card.ConfigureCategory(categories[i]); card.button.onClick.AddListener(() => { SelectCategory(index); }); //If it's not unlocked it can't be selected if (!ProgressManager.Instance.IsCategoryUnlocked(index)) { card.button.enabled = false; card.image.sprite = deactivatedImage; card.button.image.color = deactivatedCategoryColor; } } //currentLevelCreatedPanel.SetActive(false); HideLevels(); SelectCategory(currentCategory); CreateUserLevelsCards(); }
public async void getCategoryList() { categories = await JSONInterface.Instance.getCategoryData(); if (categories != null) { for (int i = 0; i < categories.Length; i++) { GameObject obj = Instantiate(CategoryPrefab, Container.transform); CategoryCard categoryCard = obj.GetComponent <CategoryCard>(); if (categoryCard != null) { categoryCard.categoryId = categories[i].CategoryId; categoryCard.categoryName.text = categories[i].CategoryName; Debug.Log(categories[i].CategoryName + " " + i); } } } }