Hello. I wanted to try to display my array prices in the game using the Example: showPrices.text ethod. It works but it only shows 1 of my arraylist. May i know how am i able to show all? My console seems to have printed the arrays. I want the same to be display as my in game. I have attached a pic so you guys can look at the problem clearly.
Here is my code
public class IngredientShop : MonoBehaviour
{
public string[ ] Ingredient = newstring[6];
public float[ ] Prices = newfloat[6];
public Text shopPrices;
inti=0;
//Usethisfor initialization
private void Start()
{
for(i=0;i<Prices.Length;i++)
{
Prices[0]=1.20f;
Prices[1]=0.90f;
Prices[2]=1.80f;
Prices[3]=1.60f;
Prices[4]=1.30f;
shopPrices.text=Ingredient_+“\t”+Prices*;_ Debug.Log(Ingredient_+“\t”+Prices); } }
i also did change the \t with \n . no difference hahahaha. oh my. Idk why but i hate tags hahah. The fact that im unsure on how to use it on this arrays hahaha. Right now, i need to know how to get the display working haha
Okay that solves the problem. However, i hope to get the script with the forloop working If you know the efficient fix, hope you can share it with me Thanks for you time mate!
the “{0}” is a placeholder for string.Format() to use
the first argument of string.Format(), is the string you are formatting, and the 2nd argument is what to replace {0} with. If i had a {1}, {2} etc i would be able to provide more arguments that it can replace with.
this is just my preference since i find it is cleaner than adding strings with +, and that it automatically calls .ToString() on anything you pass in.