void Start() { if (auto == null) { DB.Root(Application.persistentDataPath); DB db = new DB(3); //load from Resources //db = new DB(((TextAsset)(UnityEngine.Resources.Load("db2"))).bytes); // two tables(Players,Items) and their keys(ID,Name) db.GetConfig().EnsureTable <Player>("Players", "ID"); // set max-length to 20 , default is 32 db.GetConfig().EnsureTable <Item>("Items", "Name(20)"); { // [Optional] // if device has small memory & disk db.MinConfig(); // smaller DB file size db.GetConfig().DBConfig.FileIncSize = 1; } auto = db.Open(); } // set " limit 0,1 " will faster if (auto.SelectCount("from Items limit 0,1") == 0) { // insert player's score to database var player = new Player { Name = "Player_" + (int)Time.realtimeSinceStartup, Score = DateTime.Now.Second + (int)Time.realtimeSinceStartup + 1, ID = auto.Id(1) }; auto.Insert("Players", player); //dynamic data, each object has different properties var shield = new Item() { Name = "Shield", Position = 1 }; shield["attributes"] = new string[] { "earth" }; auto.Insert("Items", shield); var spear = new Item() { Name = "Spear", Position = 2 }; spear["attributes"] = new string[] { "metal", "fire" }; spear["attachedSkills"] = new string[] { "dragonFire" }; auto.Insert("Items", spear); var composedItem = new Item() { Name = "ComposedItem", Position = 3, XP = 0 }; composedItem["Source1"] = "Shield"; composedItem["Source2"] = "Spear"; composedItem["level"] = 0; auto.Insert("Items", composedItem); } DrawToString(); }