使用MongoDB
安装MongoDB(最好装C盘): https://www.runoob.com/mongodb/mongodb-window-install.html
安装可视化软件Robo3T:https://robomongo.org/
连接MongoDB实例:
using System.Collections; using System.Collections.Generic; using UnityEngine; using MongoDB.Bson; using MongoDB.Driver; public class MongodbTest : MonoBehaviour { // Start is called before the first frame update void Start() { InsertData(); } private IMongoCollection<BsonDocument> DatabaseConn() { var client = new MongoClient("mongodb://localhost"); var database = client.GetDatabase("test"); //数据库名称 var collection = database.GetCollection<BsonDocument>("WAWA");//连接的表名 return collection; } public void InsertData() { var document = new BsonDocument{ {"aa",11}, {"bb",22}, {"cc",new BsonDocument{ {"x",33}, {"y",44} }} }; var collection = DatabaseConn(); collection.InsertOne(document); } }