您好我正在unity3d 5(語言C#)需要保存一些數據到SQLite數據庫的Android遊戲項目。 遊戲沒有太多的數據來存儲它只有1個表。有一些連接到sqlite的統一插件,但我不想使用它們。 那麼如何將我的數據存儲在統一的sqlite文件?如何連接一個sqlite數據庫在統一3D 5?(無插件)
0
A
回答
4
你可以找到答案here
- 下assets文件夾中創建新的文件夾重命名爲插件。
- 複製sqlite3.def和sqlite3.dll到資產/插件在統一的項目。你可以在這裏下載這些文件 http://www.sqlite.org/download.html的Windows(預編譯的二進制 適用於Windows)
- 下載SQLite的瀏覽器http://sourceforge.net/projects/sqlitebrowser/或 http://sqliteadmin.orbmu2k.de/下載SQLite管理員工具
- 在創建數據庫使用SQLite瀏覽器在您的統一項目中的資產文件夾。
- 複製System.Data.dll中和Mono.Data.Sqlite.dll從** C:\ Program Files文件(x86)的\團結\編輯\ DATA \單聲道\ LIB \單聲道\ 2.0 *並粘貼在Unity項目的Assets/Plugins *文件夾中。
- 使用Mono.Data.Sqlite添加這些命名空間;使用System.Data;使用系統;
- string conn =「URI = file:」+ Application.dataPath +「/PickAndPlaceDatabase.s3db」;
與你的數據庫名稱替換PickAndPlaceDatabase.s3db
void Start() { string conn = "URI=file:" + Application.dataPath + "/PickAndPlaceDatabase.s3db"; //Path to database. IDbConnection dbconn; dbconn = (IDbConnection) new SqliteConnection(conn); dbconn.Open(); //Open connection to the database. IDbCommand dbcmd = dbconn.CreateCommand(); string sqlQuery = "SELECT value,name, randomSequence " + "FROM PlaceSequence"; dbcmd.CommandText = sqlQuery; IDataReader reader = dbcmd.ExecuteReader(); while (reader.Read()) { int value = reader.GetInt32(0); string name = reader.GetString(1); int rand = reader.GetInt32(2); Debug.Log("value= "+value+" name ="+name+" random ="+ rand); } reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; dbconn.Close(); dbconn = null; }
而且SQLite的幫助,請訪問:http://www.tutorialspoint.com/sqlite/
1
有一個真棒插件SQLite4Unity3d。在這個示例項目中包含了所有配置。
查看此視頻,然後您將能夠理解。
http://neeracademy.com/app-development-tips/support-sqlite-unity-app-episode-11/
相關問題
- 1. 統一的SQLite本地數據庫3D
- 2. 如何使用SQLite將數據庫表和列連接在一起數據庫
- 3. 如何使用PHP連接一個sqlite數據庫?
- 4. 如何使一個數據庫連接
- 5. 在nopcommerce插件中添加另一個數據庫連接?
- 6. 如何在sqlite數據庫中存儲統一地形數據?
- 7. 無法連接到SQLite數據庫
- 8. sqlite c#:數據庫連接無效
- 9. 如何從WindowsApplication Sqlite數據庫連接
- 10. 每個數據庫連接一個DAO?
- 11. 如何從統一連接到NodeJS數據庫?
- 12. WCF數據庫連接:只有一個數據庫連接
- 13. 連接到SQLite數據庫
- 14. Android Sqlite數據庫連接
- 15. 連接SQlite數據庫
- 16. MVC 5數據庫連接
- 17. 連接到另一個系統中的SQL數據庫
- 18. 在Swift中連接SQLite數據庫
- 19. 如何將一些數據插入到Sqlite 3數據庫中
- 20. SQLite數據庫連接:表不存在
- 21. 試圖插入到統一的c#中的SQLite數據庫
- 22. Firefox插件開發:SQLite數據庫連接
- 23. 錯誤在sqlite數據庫連接
- 24. 無法連接到數據庫,無法插入數據庫
- 25. 在另一臺計算機上的Java Sqlite數據庫連接
- 26. 數據庫與一個數據庫的各種連接
- 27. sqlite數據庫連接/鎖定問題
- 28. ASP.net一次連接兩個數據庫?
- 29. 無法在SQLite數據庫中插入一行
- 30. 我應該打開一個或多個連接到本地SQLite數據庫嗎?
我覺得這個鏈接可以幫助你:http://answers.unity3d.com/questions/743400/database-sqlite-setup-for-unity.html –