SqliteController.cs 884 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using UnityEngine;
  3. using YooAsset;
  4. namespace GFGGame
  5. {
  6. public class SqliteController : SingletonBase<SqliteController>
  7. {
  8. public void Init(bool logable, string resPath)
  9. {
  10. string dbPath = null;
  11. string connectionPath;
  12. #if UNITY_EDITOR
  13. dbPath = $"{Environment.CurrentDirectory}/{ResPathUtil.SQLITE_FILE_PATH}";
  14. #else
  15. dbPath = GetSqlFilePath(resPath);
  16. #endif
  17. #if !UNITY_EDITOR && UNITY_ANDROID
  18. connectionPath = "uri=file:" + dbPath;
  19. #else
  20. connectionPath = "data source=" + dbPath;
  21. #endif
  22. SQLiteHelper.Instance.Init(logable, connectionPath);
  23. }
  24. private string GetSqlFilePath(string resPath)
  25. {
  26. RawFileOperationHandle handle = YooAssets.LoadRawFileSync(resPath);
  27. return handle.GetRawFilePath();
  28. }
  29. }
  30. }