Unity3D如何使用Sqlite数据库

1,需要用到这几个dll文件Mono.Data.sqlite.dllsqlite3.dll和Mono.Data.sqliteClient.dll

2,将这几个dll文件放在Plugins下,必须放这里。

3,在Player Setting里的 OtherSettings里有个Optimization 下边的API Compatbility Level 选择.NET 2.0。

4,添加sqliteHelper类。这个网上有,当然也可以自己写 - -!

5,数据库要放在StreamingAssets这个文件夹下。

5,剩下的就是操作了

随便写点代码

[code]csharpcode:

01 usingUnityEngine;
02 usingSystem.Collections;
03 usingSystem.Collections.Generic;
04 usingSystem;
05 usingSystem.Data;
06 usingMono.Data.sqliteClient;
07 usingSystem.Text;
08 usingSystem.IO;
09
10 publicclassDBHelp : MonoBehavIoUr {
11 staticstringconn=string.Empty;
12 // Use this for initialization
13
14 publicstaticstringgetConstr()//得到字符串
15 {
16
17
18 #ifUNITY_EDITOR
19 conn ="URI=file:"+ Application.dataPath +"/StreamingAssets/KLandNG.db";
20
21
22
23 #elifUNITY_ANDROID
24
25
26 conn ="URI=file:"+ Application.persistentDataPath +"/"+"daniya.db";
27
28 #endif
29
30
31 returnconn;
32 }
33
34 publicstaticboolUpdateScoll()
35 {
36 inti = sqliteHelper.ExecuteNonQuery(getConstr(),CommandType.Text,
37 "update ItemInfo set name ='haha' where Type =1;"
38
39 );
40 returni > 0;
41
42
43
44
45 }
46 }

相关文章

前言 本文记录unity3D开发环境的搭建 unity安装 unity有中文...
前言 有时候我们希望公告牌跟随镜头旋转永远平行面向屏幕,同...
前言 经过一段时间的学习与实际开发,unity3D也勉强算是强行...
前言 在unity中我们常用的获取鼠标点击的方法有: 1、在3D场...
前言 在之前的例子中,我们都没有用到unity的精髓,例如地形...
这篇文章将为大家详细讲解有关Unity3D中如何通过Animator动画...