Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Albert-han · Sep 11, 2014 at 08:08 AM · gameshopin

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.

alt text

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 .

alt text

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.

picture.png (6.4 kB)
picture1.png (51.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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");
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

In Game Shop 2 Answers

Enemies Problem 1 Answer

Drawcalls in Mobile game 2 Answers

PayPal in Game Buy 2 Answers

InGame Menu (toggle) 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges