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
1
Question by AtomicMarine · Nov 22, 2011 at 04:10 PM · databasesavingsaveloadsql

Unity SQL Database?

I have many variables that need to be stored in player prefs for saving and loading, is it possible to store these variables in a database and then use SQL to call these various variables from the database, then to save the database and the next time the player plays the game it will just recall all the variables from the original database (after they have been edited)

for example if the player is using a sword with +5 damage, I could store that in a database, then the next time the player upgrades his sword to +9 damage I could Update that in the database using (UPDATE tblSwords SET damage = 9) or something along those lines, instead of constantly having to save and load player prefs?? is this possible?

Comment
Add comment · Show 3
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 AtomicMarine · Nov 22, 2011 at 04:11 PM 0
Share

Also I use a $$anonymous$$ac, so what would be a good program to store the database? also is any of this possible? I need it for an iPhone game.

avatar image thorbrian · Nov 23, 2011 at 12:03 AM 0
Share

see answer below - but I have to say - a database for what you describe sounds like complete overkill, a lot of extra hassle, and not feature rich enough for some things you'd want. A database isn't really better than player prefs - and saving out playerprefs isn't as much overhead as saving out a database. Also, I would think the best solution would be one that involves serializing a hierarchy of objects that may be nested in interesting ways - like say the player's inventory contained a bag that had a sword in it. With serialized objects, that kind of thing is trivial to represent, but it's very awkward to do with databases.

avatar image AtomicMarine · Nov 23, 2011 at 04:16 AM 0
Share

Thanks for the heads up ^^ I was just considering the database because I have various scenes with objects that the player can place and I need to store the positions of all those objects :/ been using an array so far, going to try a few other things and see how it works

3 Replies

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

Answer by thorbrian · Nov 22, 2011 at 11:57 PM

You can use the SQLite in Mono if you want - you just need to copy the "Mono.Data.dll", "Mono.Data.Sqlite.dll" and "Mono.Data.SqliteClient.dll" files from "C:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0" (or whatever is the equivalent dir for you) somewhere under your projects asset folder (don't think it matters where), and then the "Mono.Data.SqliteClient" namespace should be available for use.

Comment
Add comment · Show 3 · 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 randomuser · Mar 23, 2013 at 12:44 AM 1
Share

Will this work in unity basic? This approach requires plugins

avatar image wasix · Feb 13, 2014 at 12:17 PM 0
Share

to the person who posted the download: i am an extreme noob to unity, would you $$anonymous$$d making a sample package with the download you created? i would be explosively grateful.

avatar image thready · Sep 23, 2014 at 01:14 AM 0
Share

I wonder if anyone knows the answer to that- will this work in Unity basic?

Thanks, $$anonymous$$ike

avatar image
5

Answer by busta-gara · Apr 17, 2013 at 08:00 PM

hi, you can use this code its easy to use and its free for your individual use,

use example:

 SqliteDatabase sqlDB = new SqliteDatabase(“config.db”);
 string query = “INSERT INTO User(UserName) VALUES( ‘Santiago’)”;
 sqlDB.ExecuteNonQuery(query);

its so easy… the file “config.db” is necessary exist in the “StreamingAssets” folder

i hate the people who sell this things in the assets store, something easy like this… we need more open sources users :)

link --- > click here to download

link --- > GitHub Repository

works on iOS, MAC OSX, Windows, i dont sure if works on web and android, if you test in that OS tell me the result.. thanks

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 jojizaidi · Aug 18, 2015 at 07:46 AM 0
Share

Hey,

This is working for me on mac.. But when I do this on windows I get DllNotFoundException: sqlite3

Any thoughts?

avatar image bastischo · May 12, 2016 at 09:43 PM 0
Share

I Tried Android and Windows. Works really well. One Thing: You NEED to do what the readme says about copying some sqlite3 file to Assets/Plugins/Android

avatar image
-1

Answer by braidykens29 · May 31, 2013 at 04:35 PM

Apply mssql fix database

Article http://www.sqlserver.fixtoolboxx.com will help you to give the proper understanding about sql databases

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 BananaClipStudio · Sep 15, 2014 at 11:48 PM 0
Share

yeah nice plug

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

9 People are following this question.

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

Related Questions

Using Unity to connect to a Database 3 Answers

A node in a childnode? 1 Answer

Saving Huge strings over the web 3 Answers

Can't connect from Unity 3.1 to SQL Server Express 8 Answers

using SQL db instead of playerprefs (playerlocation) 0 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