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 sona.viswam · May 13, 2013 at 05:59 AM · database

Database in unity 3d

In my game whenever user opens the game , it should fetch value from a url

 void Start () {
     string url = "http:/myurl";
     WWW www = new WWW(url);
             StartCoroutine(WaitForRequest(www)); 
 }
 
 IEnumerator WaitForRequest(WWW www)
 {
     yield return www;
 
     // check for errors
     if (www.error == null)
     {
         Debug.Log("WWW Ok!: " + www.data);

     } else {
         Debug.Log("WWW Error: "+ www.error);
     }    
 }

I want to save this data in database to use in game.

I am not aware of databse in unity.

Which is the best method for it .

i only know about PlayerPrefab. Any other good method exist?

If user is not connected he should play with already saved data in mobile. Need good advice and solution ?

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 Fattie · May 13, 2013 at 06:37 AM 0
Share

There are a number of SQL products on the Asset Store.

You (or anyone reading who's a beginner) will have to learn SQL database program$$anonymous$$g, at least in a simple way, if you want to use a database.

There's really nothing wrong with using PlayerPrefs for even quite a lot of data .. why not?

Tip - use Secured PlayerPrefs (asset store) for any real-life project.

avatar image sona.viswam · May 13, 2013 at 08:07 AM 0
Share

can we save as xml file?

avatar image nisanthkumar · May 13, 2013 at 12:08 PM 1
Share

How to make a new database/table and insert values into it

2 Replies

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

Answer by Mexallon · May 13, 2013 at 06:24 AM

Hej there. If you want a small database with not much of a content and without necesarrily internet connectivity I recommend you Sqlite. This is just a file that contains the data but you can access it just like normal SQL.

There are some free Plugins available I used it a while ago and it worked well in Unity

Comment
Add comment · Show 13 · 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 Mexallon · May 13, 2013 at 10:27 AM 1
Share

Yeah sure. Take a look at this project at github. Just add the class to your project then you should be able to create a sqlitedatabase class and send queries to it. If you dont have a clue about SQL syntax and usage yet you should catch up that first before using sql.

avatar image Mexallon · May 13, 2013 at 11:04 AM 1
Share

create a new c# script, copy this in and add it to your camera. should work

 public class Sqlite : $$anonymous$$onoBehaviour {
     private SqliteDatabase db;
         void Start(){
                 db = new SqliteDatabase("database_name_here_with_extension");
                 db.ExecuteQuery("SELECT * FRO$$anonymous$$ table_name;");
         }
 }
 
avatar image Mexallon · May 13, 2013 at 11:14 AM 1
Share

Put the sqlitedatabase.cs file and everything you've downlaoded from the github page into a folder named "Plugins" in your Assets folder. If it doesnt exist already create it.

avatar image Mexallon · May 13, 2013 at 11:27 AM 1
Share

$$anonymous$$y bad. the name of the method is ExecuteQuery not just query

avatar image Mexallon · May 13, 2013 at 11:38 AM 1
Share

should i create database using query

you could. but use another script/project for that. but more comfortable is to use a client to do this. Under OSX iam using "SQLite$$anonymous$$anager" for example

where i have to add db name and column name.please explain.

the name of the db is the parameter for the constructor (in my example above "database_name_here_with_extension" The column name is part of the query, in my example "*" it could also be "id" or "id, name"

Show more comments
avatar image
0

Answer by Ebil · May 13, 2013 at 07:36 AM

For simple usage you can call a PHP script thats accessing the database. But I think that wouldnt be so secure.

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

17 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

Related Questions

Unity3d and Database and MultiPlayer Games 1 Answer

Umlaute missing in Unity GUI. 1 Answer

Problem in starting mysqld Process 0 Answers

MySql Online Character About 0 Answers

Unity 3D and Databases? 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