54 lines
		
	
	
		
			945 B
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			945 B
		
	
	
	
		
			C#
		
	
	
| 
 | |
| 
 | |
| using SQLite4Unity3d;
 | |
| 
 | |
| namespace Guru
 | |
| {
 | |
|     using System.Collections.Generic;
 | |
|     
 | |
|     
 | |
|     
 | |
|     public class GuruDB
 | |
|     {
 | |
| 
 | |
| 
 | |
|         private static GuruDB _instance;
 | |
|         public static GuruDB Instance
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 if(_instance == null) _instance = new GuruDB();
 | |
|                 return _instance;
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         public int dbVersion = 1;
 | |
|         public string dbName = "guru";
 | |
|         private DBService _dbService;
 | |
|         internal DBService Service => _dbService;
 | |
|         public bool IsDebug { get; private set; } = false;
 | |
|         public bool IsReady { get; private set; }
 | |
| 
 | |
|         public GuruDB()
 | |
|         {
 | |
| #if UNITY_EDITOR
 | |
|             IsDebug = true;
 | |
| #endif
 | |
|             _dbService = DBService.Open(dbName, IsDebug);
 | |
| 
 | |
|             IsReady = _dbService != null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
| 
 | |
|     public interface IDBItem
 | |
|     {
 | |
|         [PrimaryKey]
 | |
|         string id { get; set; }
 | |
|     }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| } |