- Home /
In-Game Shop Problems
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.
Answer by PAHeartBeat · Sep 11, 2014 at 11:45 AM
Hi Albert,
First Of-all your class should be Serialzable to show in unity editor inspactor. after that you can create a variable of as List or array to edit in editor mode.
Second in your GUI Layout you make only two buttons, I thought you have also use GUI.BeginColomn and GUI.EndColumn to make left-right view of your GUI buttons.
you can achive it using for loop for. and put this code in between of GUI.BeginColumn and GUI.EndColumn in-side of for loop
 if (GUILayout.Button(iconButtonLabel))
 print ("you clicked the icon");
  
 if (GUILayout.Button(textButtonLabel))
 print ("you clicked the text button");
Your answer
 
 
             Follow this Question
Related Questions
In Game Shop 2 Answers
Why are my assets not showing up in the Scene panel? 2 Answers
In-game Shop / Market/ Buying / inventory system? 3 Answers
Embed my game in my Homepage? How? 0 Answers
Character shop 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                