首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >数据在使用sqlite数据库的VR中不显示

数据在使用sqlite数据库的VR中不显示
EN

Stack Overflow用户
提问于 2019-12-10 17:14:37
回答 1查看 270关注 0票数 0

我的VR Oculus rift有一个高分表,我想将数据保存到sqlite数据库并显示来自VR耳机的数据,但是只有unity能够显示来自数据库的数据到高分板,当我将游戏从unity导入到oculus rift时,VR耳机甚至没有显示来自数据库的任何数据。

下面是我用来显示比分的代码,它只能在unity内部工作,而不能在vr耳机上工作:

代码语言:javascript
复制
 private void GetScores()
    {
        highScores.Clear();


            using (IDbConnection dbConnection = new SqliteConnection(connectionString))
            {
                dbConnection.Open();

                Debug.Log("DB Step 1");
                using (IDbCommand dbCmd = dbConnection.CreateCommand())
                {
                    Debug.Log("DB Step 2");
                    string sqlQuery = "SELECT * FROM highscoresss";
                    dbCmd.CommandText = sqlQuery;

                    using (IDataReader reader = dbCmd.ExecuteReader())
                    {
                        Debug.Log("DB Step 3");
                        while (reader.Read())
                        {
                            Debug.Log("DB Step 4");
                            highScores.Add(new HighScore(reader.GetInt32(0), reader.GetString(1), reader.GetString(2)));


                        }
                        Debug.Log("DB Step 5");
                        dbConnection.Close();
                        reader.Close();
                    }
                }
            }


    }
void Start()
    {
        connectionString = "URI=file:" + Application.dataPath + "/StreamingAssets/mydatabasess.db";
        ChangingText.text = connectionString;
        ShowScores();
    }

我使用Andriodlog捕获错误,它一直显示错误连接数据库:sqlite3

vr Oculus rift错误消息androidlog:

数据整齐划一的高分表:

EN

回答 1

Stack Overflow用户

发布于 2019-12-14 06:05:17

看起来问题出在数据库路径上;你正在为你的Android版本修改它吗?流式资源通常由Unity复制到特定位置accessible through different means depending on the platform。如果我是您,出于调试目的,我会检查您的数据库文件是否在您期望的位置。

代码语言:javascript
复制
if (!File.Exists(yourDatabasePath))
    Debug.Log("Couldn't locate database at {0}",yourDatabasePath);

如果这最终成为罪魁祸首,使用streamingAssetsPath或只是将数据库复制到设备上的持久存储中,然后通过新路径正常访问它可能会更容易,这将为您的Oculus构建定义如下:

代码语言:javascript
复制
string yourDatabasePath = 
#if UNITY_EDITOR
    "Assets/StreamingAssets/mydatabasess.db";
#else
    "sdcard/MyAppFolder/mydatabasess.db"; //just an example
#endif
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59263744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档