using System.Collections; using System.Collections.Generic; using UnityEngine; using Mono.Data.Sqlite; // 注意:這取決於你使用的SQLite庫 public class SQLiteExample : MonoBehaviour { // 資料庫檔案路徑 private string dbPath = "URI=file:" + Application.dataPath + "/MyDatabase.db"; void Start() { // 示例:連線資料庫並建立表 SqliteConnection conn = new SqliteConnection(dbPath); conn.Open(); string createTable = "CREATE TABLE IF NOT EXISTS Players (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "score INTEGER)"; SqliteCommand cmd = conn.CreateCommand(); cmd.CommandText = createTable; cmd.ExecuteNonQuery(); conn.Close(); Debug.Log("資料庫表已建立或已存在。"); } // 其他資料庫操作... }
#############################