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
0
Question by Subject-Gabz · Aug 05, 2016 at 06:31 PM · c#serializationdatabaselistssqlite

SQLite and Lists in C#

Hello everyone,

I've been creating a game and I've recently started using database to store data and wondering how to do it online and offline.

I am using SQLite 4 Unity 3d (and sincerely don't know if it is the best way to store data in C#), and I'm able to save information as long as it is intenger, float, strings, etc.

But I recently needed to save a list of strings, or numbers, and I've been strulling a bit to understand the concept behind this (since I'm a newbie with database, XML, SQL, and anything related to saving data offline or online).

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 namespace SQLite.models{
     public class PlayerClass{
 
         [PrimaryKey, AutoIncrement]
         public int level {get; set;}
         public float money {get; set;}
 
         private List<string> tanksOwnedName {get; set;}
 
         [SerializeField]
          public string tanksOwnedNameJSON { 
             get {
                     return StringSerializationAPI.Serialize(tanksOwnedName.GetType(), tanksOwnedName);
             }
             set {
                     tanksOwnedName = (List<string>)StringSerializationAPI.Deserialize(tanksOwnedName.GetType(), value);
             }
         }
     }
 }

What you can see above is a Player class where the player will own tanks in this case.

Can someone enlighten me with databases, does and donts, with storing data online and offline.

Many Thanks in advance to all of you.

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 Gilead7 · Aug 08, 2016 at 05:04 PM 0
Share

You may want to look into using a JSON string to collect your data and the database to store it. Just make sure to use a coroutine for any online server saves so it will wait long enough to perform the operation. The only problem locally is to initialize your commands before using them. Since you are using a namespace, you should be fine. I would shy away from using X$$anonymous$$L, JSON is much cleaner, faster and better all around.

1 Reply

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

Answer by GilbertoBitt · Aug 08, 2016 at 04:38 PM

for me the best way offline was creating a persistent file like txt, xml or samething like that.. and in game using scriptable objects to store all data through all scenes.. and when i use online services i send this data trough json utility. and that's it! i already like u use this sqlite but what i see on this plugins it's too complicate for simple things... i hope my answer helped you! any questions feel free to do it.

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

6 People are following this question.

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

Related Questions

Assistance needed with serialization, inheritance and scriptableobject 1 Answer

Unity build cant find serialized file after restarting 0 Answers

Best practices for multiple databases 1 Answer

How to get a database with information in it to be usable in a build 0 Answers

Serialization Error 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