Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 darkcookie · Jul 06, 2012 at 09:53 PM · inventorystore

how to store items in inventory?

I made an inventory trough GUI which consist of a toolbar with 6 windows.... 1.)Tms and Hms 2.)items 3.)Medicine 4.)Pokeballs 5.)Berries 6.)keyItems

ok, the problem is that i don't know how to store items in these ..well how can i save information in these because i only need the name of the object to list inside the window..... i was thinking of making a class for each of the 6 windows ...but i just don't know how to do it ...if any one can point me in the right direction with a script or by suggesting some advice it would be much appreciated.

Comment
Add comment · Show 2
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
avatar image Rafes · Jul 06, 2012 at 10:22 PM 0
Share

What do you mean by "store the items in these". Are you talking about the GUI or storing the results of the GUI? It sounds like you are looking for program$$anonymous$$g patterns that might lead to an elegant way to work with the inventory in the game, but please clarify what specific discussion you are after. Also, this may be better off posted to the scripting forum for discussion, unless you can ask a concise question.

avatar image darkcookie · Jul 06, 2012 at 10:31 PM 0
Share

ohh ok i mean how can i store the information (name) of items u puck up or u have in the inventory ..and yea store the names on the GUI...well i gess what im asking how can i store information and then read information?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Rafes · Jul 06, 2012 at 10:46 PM

You should not store information in your GUI. Your GUI should only handle the displaying of, and interaction with, information found in primary objects/managers/controllers (pick your favorite name).

For example, I have an object in 3D space that can be clicked on. It has a single call to my HUD class TargetHUD.Display(this). The HUD knows how to take it from there. They don't need to know about each other or get tangled in shared code.

So, your inventory should probably just display items found in a list in whatever script you use to manage the state of your player. You may want to make an InventoryItem class with basic information that all inventory items will need, which depends on your game, such as wearable slots, like arms or legs, or number of uses, etc. Then you can use a list on your player.

When the inventory comes up, it simply needs to access this list and based on the information, display everything. When changes are made, it should write the changes to the items, or add/remove items from the list.

This is just one possible design pattern. It is very dependent on your game's needs.

Comment
Add comment · Show 2 · 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
avatar image darkcookie · Jul 06, 2012 at 10:59 PM 0
Share

O$$anonymous$$G YES :DD ty ...thats what i was asking ...like how do i make the class script that can save info and how can i read that info?

avatar image Rafes · Jul 06, 2012 at 11:16 PM 1
Share

I would just mark this answered and continue on the forums. What your asking is basic code knowledge. For example, I have a script "InventoryItem" and a script "Player" with a list, then i can add InventoryItems to the list. When I launch my inventory for this player, I can read the list and use the items to make my inventory. The details depend on your game. For example, do you have one player, or might you have more? If the inventory should belong to the player, you might want an "Inventory" script on the player gameObject that has the list and also manages any other stuff you might want, like "gold", etc, then your Inventory GUI could read the players Inventory script to initialize the display. I suggest understanding the basics of the code first, then think about how it logically applies to your game. ...and don't forget to click the thumbs up button here when a post or comment helps ;)

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

PlayFab: KeyNotFoundException: The given key was not present in the dictionary. 0 Answers

Cannot convert from 'int' to 'PlayFab.ClientModels.ItemInstance' 1 Answer

How to store gameobjects to create an inventory. 3 Answers

First person pick up object and store into inventory? 0 Answers

Text RPG inventory 1 Answer


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