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
3
Question by save · Jun 16, 2011 at 07:07 AM · savedatabaselocal

Local database method?

In our upcoming game we have about 100 levels with different characteristics (some are mini-games, some give more points than others, some unlocks others etc). So far I've been storing the values in an array which is structured via a class and built upon start. It works fine but I was wondering if there's a more clever way (iterate through an external xml at start perhaps?).

One benefit I'm looking for is to have a table structure of the database to be able to edit and view it in an external program. What would be easiest to use in this case?

Comment
Add comment · Show 4
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 save · Jun 16, 2011 at 02:24 PM 0
Share

Anybody who has experience in handling information with lots of data for Unity? - Not looking for code but only advice in which direction to go.

avatar image save · Jun 17, 2011 at 09:44 AM 0
Share

It's not possible to add bounties anymore to questions right?

avatar image Chris D · Jun 22, 2011 at 10:53 PM 1
Share

@save it's probably worth opening a thread on the forums for the advice thing.

avatar image save · Jun 22, 2011 at 11:12 PM 0
Share

@ChrisD Yeah you're right, this ends up in a quite broad topic.

1 Reply

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

Answer by AlanChatham · Jun 22, 2011 at 05:26 AM

You could try using SQLite. Especially if you're coding using Javascript (or if you're not, if you can throw your javascript into the plugins folder and not have any other plugin scripts call it), it's fairly easy to integrate SQLite into your projects. You may have to copy some DLLs around to get it working, but it's pretty easy. Do some more research if you want to implement it in C#, as apparently there's a little bit more moving stuff around to get dependencies to work.

As someone with zero knowledge of database stuff, it took me an hour or two to figure out how to get everything compiling, then a few more hours to learn how to play with SQL databases, but it wasn't TOO painful. I'm using this code:

http://forum.unity3d.com/threads/28500-SQLite-Class-Easier-Database-Stuff

and I think this post was helpful to get things set up? I should make a good guide on the wiki...

http://forum.unity3d.com/threads/7866-Unity-and-Sqlite

At any rate, then it's easy to mess around with your database (which in SQLite's case is just stored as a local file) with this program:

http://sqlitebrowser.sourceforge.net/

Comment
Add comment · Show 10 · 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 AlanChatham · Jun 23, 2011 at 01:44 AM 1
Share

Of course, you HAD to go and comment about a wiki page, so I had to make one ;) At any rate, here you go!

http://www.unifycommunity.com/wiki/index.php?title=SQLite

Please, though, if you want to try this out (and haven't already messed around with any of the SQLite stuff), if you could follow the instructions exactly and let me know how it works, it'd be super-helpful. I built the instructions around starting with a blank project, but of course I've also installed various SQLite stuff as part of trying to get things to work in different ways, so if you could confirm that the instructions work on a virgin machine, it would be super-helpful for the guide.

avatar image AlanChatham · Jun 23, 2011 at 02:05 PM 1
Share

You're welcome! I figured I should do it while it's still fresh; I'm just starting up with it myself, and I figured it'd be best to extend and share the GUI stuff I've been building before it gets loaded up with a bunch of stuff that's my-application specific. I'm also really glad it works with a clean build - maybe I'll figure out how to put it together in C# (since my project is mostly in C#, and I don't want to waste compile time by having a bunch of code in my Plugins folder..)

What do you mean, exactly, by 'in a build, access the database'? Are you talking about getting and setting entries in the database as your program runs? I suppose the dbAccess class isn't really fully fleshed-out, and has no nice Update function lying around, but to read individual data in your application, you'll want a script with a dbAccess variable, and then you'll make calls on that dbAccess object to access your variable. So you never have access to a singular database object in your game; ins$$anonymous$$d, you've got scripts that have accessor objects that allow you to run SQL commands on your database, whether it's with pretty commands like dbAccess.SingleSelectWhere(...)(I added an example usage to the comments in the code) or whether it's with the ugly but general purpose dbAccess.BasicQuery(...). But please clarify if that's not what you mean. Although, now that you mention it, at least a link to the $$anonymous$$SDN references about IDbCommand may be useful to help figure out how values are returned by the commands.

avatar image AlanChatham · Jun 24, 2011 at 04:51 AM 1
Share

Thanks so much for looking more deeply into this than I have! I wouldn't have thought to make an actual build, and it turns out the current instructions weren't actually compiling into something that worked. It turns out that what I thought was pretty basic in Javascript is a bit more finicky than I originally thought. I've updated the wiki, including a $$anonymous$$or update to the code. On the plus side, by importing $$anonymous$$ono.Data.SQLite ins$$anonymous$$d of SQLiteClient, it can find the DLL and you don't have to move it yourself.

As for full builds, on the downside, I did find that in order to get builds to work properly, you need to go download sqlite3.dll from the SQLite people and put that into your plugins folder. It results in me getting a license error, since I only have Indie, but it still seems to run just fine. Not surprising, maybe, since in the editor, you don't have to have sqlite3.dll in your project folder for everything to work. And, lo and behold, it doesn't stop me from compiling a stand-alone build that works (but that build only works if I have sqlite3.dll in my project's Plugins folder).

But, you don't have to do any manual moving. So long as you have sqlite3.dll in your project's Plugins folder, it'll spit out a working application. However, I haven't looked into how you'd go about packaging that with an existing database to read from - my example application creates a new database the first time it's run, and from then on, it's persistent across sessions. So it's ideal for savegames, or I'm using it to import outside databases from a different application, but you may need some sort of external installer which will package the stand-alone build together with any initial databases you'd like the program to load from on it's first run.

So it's working smoother than ever now, but I need to ask some questions of my own I guess to figure out this license/build issue...

avatar image AlanChatham · Jun 24, 2011 at 05:22 AM 1
Share

I did figure out an alternate work-around for putting SQLite3.dll in the plugins folder and getting a licensing error. If you copy sqlite3.dll into the same folder as the .exe file of your build, your application will find it and run correctly.

avatar image raminsh · Apr 15, 2012 at 08:18 AM 1
Share

great information

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Saving Database from server to local and read from there (android) 0 Answers

Accessing the computer's local files 1 Answer

NSqlite problem findwhere or read value from database 0 Answers

Accessing local system ( File Browser ) 2 Answers

Save Players Creation to be opened later 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