【发布时间】:2021-08-05 21:28:57
【问题描述】:
我在我的游戏中添加了一个数据库,当我在 Unity Editor 中签入时一切正常,但是当我在手机上运行游戏时出现错误 no such table: Users 虽然数据库有这个表
我的代码
private void ConnectData()
{
#if UNITY_EDITOR
_path = Path.Combine(Application.streamingAssetsPath, "russianWords.bytes"); //Path to datab
#elif PLATFORM_ANDROID
_path = Application.persistentDataPath + "russianWords.bytes";
if (!File.Exists(_path))
{
Debug.Log("4");
string timlesPath = "jar:file://" + Application.dataPath + "!/assets" + "russianWords.bytes";
Debug.Log(timlesPath);
WWW load = new WWW(timlesPath);
while (!load.isDone) { }
File.WriteAllBytes(_path, load.bytes);
}
#endif
_dbConnection = new SqliteConnection("URI=file:" + _path);
_dbConnection.Open();
if (_dbConnection.State == ConnectionState.Open)
{
m_sqlCmd = new SqliteCommand();
m_sqlCmd.Connection = _dbConnection;
}
}
private void CheckEndGame()
{
if(ResultWords.Count - 1 >= GameManager.Instance.TargetWordsAmount)
{
string words = "";
foreach(var p in ResultWords)
{
if(p != "КОЛА")
words += p + ", ";
}
ScrambleInterface.Interface.OpenResultPanel(words);
}
}
【问题讨论】:
-
我看不到您访问该表的位置。
while (!load.isDone) { }应该做什么? -
这个循环将一直运行,直到表格被加载。
-
是的,但
load.isDone不会在循环内部发生变化,是吗? -
是的,如果循环改变,那么代码会更进一步
-
@Charlieface 过时
WWW异步运行,因此isDone将在单独的Task上变为true。