Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by ImpMontezuma · Feb 17, 2019 at 07:41 PM · best practicesdatabase handling

Noob question about best practice in managing game data

Hi, I'm new to Unity, and I'm planning to make a game that contains a lot of characters with lots of information on each. So, I would like to know what is the best practice to manage the characters data? Should I turn each of them into specific objects and take them scene to scne with the DontDestroyOnLoad method? Should I keep a single object with all the characters' data in the game and use it to instantiate a prefab when a need them? Should I keep saving the data in the hard drive and load it in the generic prefab of personages when I need them? Or some other technique?

I'm not sure, because I see problems in all the technique I've listed above.

1) The first one seems to me to not represent the idea of game model in Unity 2) The second seems to not represent the basic idea of ​​the technique of object orientation, which says that each object must take care of itself. 3) The third one seems to me that it would make a bad optimized game. And moreover it would make my life very difficult, because in some moments of the code I would need to compare data of all the characters at the same time.

Anyway, does anyone have a suggestion?

Comment
Add comment · Show 1
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 zereda-games · Feb 18, 2019 at 12:00 AM 0
Share

@Imp$$anonymous$$ontezuma Have you looked into ScriptableObjects? This is a very handy tool. A quick search on google will get you a Unity Api and $$anonymous$$anual links on the first 2 links.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by pigaroos · Feb 17, 2019 at 09:02 PM

Im pretty sure you can make a preload scene, and store all your information there. Check this out and see if it is what you are looking for: https://stackoverflow.com/questions/35890932/unity-game-manager-script-works-only-one-time/35891919#35891919

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 ImpMontezuma · Feb 17, 2019 at 09:43 PM 0
Share

This is an interesting technique. But unfortunately it doesn't solve all my problems ^^". $$anonymous$$ainly because I was thinking of working with asset bundle to add new characters to my game as $$anonymous$$ods. And as far as I know, the way to do this is to add them to the game as prefabs.

And if you read the last message, forget about that, I was thing about a instance of a object inside a prefab (probably impossible to do, I know) So... I guess I need to think more about this problem ^^ "

avatar image ImpMontezuma · Feb 17, 2019 at 10:52 PM 0
Share

Anyway. I think the solution 1) is out of the question, so I go for solution 2, which is actually very similar to the one you recommended. So thank you, This topic gave me an idea of how in general people solves this kind of problem in Unity.

avatar image
1

Answer by Cornelis-de-Jager · Feb 17, 2019 at 09:32 PM

@ImpMontezuma None of the above! Infact the best way I found is to simply store them in folders inside your assets. "But wiat! How can that be? You can't access your assets IN GAME!!" ~ But thats where you are wrong! Simply pop them into the Resource folder and Bobs your aunt (can't assume gender these days)! All you need to do is Resources.Load<GameObject> ("My Path") or Resources.LoadAll<GameObject>("My Path") and you can have it accessible from any script. BOOM - Link to doco!


But now you must be thinking: "FOOL, the property data of the characters change and needs to be retianed between sessions!" Well fear not! Your C#/Unity mastery is but a few lines of code away - Introducing... JSON.


In-fact, JSON is so good to use the Unity Peeps made a step by step tutorial on how to do it RIIIIIIIIIIGHT here.


May the odds be ever in your favor.

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 Spacejet13 · Feb 17, 2019 at 10:17 PM 0
Share

Beat me to it!

avatar image ImpMontezuma · Feb 17, 2019 at 10:22 PM 0
Share

Well, in fact that tecnique is exactly was I saying about "keep saving the data in the hard drive and load it in the generic prefab of the characters when I need them"... And worse, after thinking hard about it, this technique doesn't solve the problem itself, because I would still have to use one of the other two technique to work with this deserialized json data anyway :( Hahaha I didn't think such a simple problem would create such confusion in my $$anonymous$$d ^^ " That's because, as I said, at some point in the code, I would have to compare the date of all the characters at the same time. But thank you for your answer.

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

102 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is there preferred project folder structure that should be used when setting up your project? 1 Answer

Best practice to query a material/shader for a main color? 1 Answer

SOLID principles 0 Answers

How to store 3D object(Furniture models) files (.fbx) and then instantiate one or more in runtime.? how to create database for it? 1 Answer

Best Practices: TimeSpans 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