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 GeorgeRigato · Mar 01, 2013 at 03:28 PM · serializationinventorysavingsingleton

Singleton Inventory

Yesterday I asked a question regarding serialized class of a inventory system.

Today is a related question(s), but as is a different one, I thought that would be nicer to post it as another thread.

A-Is it smart to design a inventory system as a singleton? B-How the saving would be? C-The singleton should be or not a MonoBehavior?

I'll stop here.

Thanks!

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
1

Answer by WilliamLeu · Mar 01, 2013 at 05:26 PM

A) I didn't see your original question, but I think it depends on your game and its design, no reason that wouldn't work though. Just make sure that the inventory class only belongs to one character. If you have an inventory class that manages the inventory of all/multiple characters, might as well store the inventory information in the individual respective characters.

B) The differences in performance and resources are so small that I wouldn't worry about it. Worry about what's more elegant conceptually, and what's the most sane to implement.

C) If you were going to have a singleton, I would recommend making it a MonoBehaviour. I would have a "GameManager" GameObject in the scene where all the singletons and global states go. Then in the Awake() function of the singletons, have it set the static instance to itself. That keeps things modular (in the spirit of MonoBehaviours), and you can expose variables through the inspector during edit and runtime. You do loose the ability to change the code during runtime without restarting the game though with static variables to MonoBehaviours.

Comment
Add comment · Show 1 · 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 GeorgeRigato · Mar 05, 2013 at 01:34 PM 0
Share

i'm really not sure about how to pull this out.

Of course I'm implementing some other features of the project, but this is a key one and my "time is running out". (remember Command and Conquer: Red alert sound track?)

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

10 People are following this question.

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

Related Questions

Need experienced opinion: Saving a players inventory: XML or PlayerPrefs? 1 Answer

SerializationException: serializationStream supports seeking, but its length is 0 1 Answer

Button OnClick() function stops working after instantiating the prefab. 1 Answer

How do you save changes made with custom editor? 3 Answers

Is it possible to save an object array? 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