public void Set(PortionRecipe portionRecipe) { _txt_price.text = portionRecipe.price.ToString(); foreach (Image img_tier in _imgs_tier) { img_tier.gameObject.SetActive(false); } int baseIndex = 0; for (int i = baseIndex; i < baseIndex + portionRecipe.tier0; i++) { _imgs_tier[i].gameObject.SetActive(true); _imgs_tier[i].sprite = _sprites_tier[0]; } baseIndex += portionRecipe.tier0; for (int i = baseIndex; i < baseIndex + portionRecipe.tier1; i++) { _imgs_tier[i].gameObject.SetActive(true); _imgs_tier[i].sprite = _sprites_tier[1]; } baseIndex += portionRecipe.tier1; for (int i = baseIndex; i < baseIndex + portionRecipe.tier2; i++) { _imgs_tier[i].gameObject.SetActive(true); _imgs_tier[i].sprite = _sprites_tier[2]; } baseIndex += portionRecipe.tier2; for (int i = baseIndex; i < baseIndex + portionRecipe.tier3; i++) { _imgs_tier[i].gameObject.SetActive(true); _imgs_tier[i].sprite = _sprites_tier[3]; } baseIndex += portionRecipe.tier3; }
void LoadPortionRecipeCSV() { portionCsvFile = Resources.Load("portionRecipe") as TextAsset; // Resouces下のCSV読み込み StringReader reader = new StringReader(portionCsvFile.text); // , で分割しつつ一行ずつ読み込み // リストに追加していく while (reader.Peek() != -1) // reader.Peaekが-1になるまで { string line = reader.ReadLine(); // 一行ずつ読み込み string[] data = line.Split(','); PortionRecipe portionRecipe = new PortionRecipe(); portionRecipe.tier0 = int.Parse(data[0]); portionRecipe.tier1 = int.Parse(data[1]); portionRecipe.tier2 = int.Parse(data[2]); portionRecipe.tier3 = int.Parse(data[3]); portionRecipe.price = int.Parse(data[4]); portionRecipeList.Add(portionRecipe); // , 区切りでリストに追加 } }