private void Start() { itemLabel.text = Regex.Replace(ItemName, "([a-z])([A-Z])", "$1 $2"); Sprite spr = ResourcesDatabase.GetSprite(ItemName); if (spr != null) { itemSprite.sprite = spr; } foreach (string s in ResourcesDatabase.GetIngredients(ItemName)) { GameObject go = Instantiate(ingredient); go.transform.SetParent(ingredientGrid.transform); string[] d = s.Split(' '); IngredientInfo ing = go.GetComponent <IngredientInfo>(); ing.Info = s; ing.LoadSprite(d[1]); //set sprite of go's image to whatever the ingredient is } }
void LoadIngredients() { string[] i = ResourcesDatabase.GetIngredients(product); //if this generator requires fuel to operate, add +1 to the length of the ingredients list int length = Fuel != ResourceType.END ? i.Length + 1 : i.Length; IngredientsPer100 = new int[length]; Ingredients = new string[length]; IngredientsStored = new int[length]; int index = 0; foreach (string s in i) { string[] split = s.Split(' '); if (split.Length != 2) { Debug.LogError("Bad info for " + product + " ingredient(s)"); } IngredientsPer100[index] = int.Parse(split[0]); Ingredients[index] = split[1]; index++; } if (Fuel != ResourceType.END) { int fuelIndex = length - 1; Ingredients[fuelIndex] = Fuel + ""; } if (Fuel != ResourceType.END) { IngredientsPer100[index] = DeteriorationPerCycle; } }