Hi guys,Thanks for clicking and looking into this topic.I am quite stuck on implementing an in-game shop into my game since yesterday.But here’s my problem now.
I am using this script for my shop
private void Shop(Rect position, Buyable buyable)
{
if(GUI.Button(new Rect(0,375,128,32),"Back"))
{
ToMenu("Main");
}
{
GUIContent iconButtonLabel = new GUIContent(buyable.CharTexture, "Some Tooltip");
GUIContent textButtonLabel = new GUIContent(buyable.name, "Another Tooltip");
GUILayout.BeginArea(position);
if (GUILayout.Button(iconButtonLabel))
print ("you clicked the icon");
if (GUILayout.Button(textButtonLabel))
print ("you clicked the text button");
GUILayout.EndArea();
}
}
Rect rectangle = new Rect(100,150, 150, 100);
Buyable buyableItem = new Buyable();
A list for editing the shop in editor
public class Buyable
{
public string name;
public Texture2D CharTexture;
public int Cost;
}
The problem is now is that it doesnt work.Here’s a screenshot of what i get.
No matter how many elements i add into the List(in editor)it doesnt show up the number of elements i put in editor.And if i put 0 elements it shows up.
I want it to look like this .
And for every element i add in editor,there will be another one with the 2d texture and name i assign in editor a few pixels away.Like the shop and play will replace with all the cars i put in editor.