Unity中的Sqlite

时间:2015-12-18 15:02:08

标签: c# database sqlite unity3d unity5

这是我的代码正常工作。我遇到的唯一问题是,当我登录时,它不会加载我的级别。这是我的代码。

public void Loginfunc()
{
    string usernameforsignin = UsernameSignin.text;
    string passwordforsingin = PasswordSignin.text;

    if (usernameforsignin == "sdsefa" || passwordforsingin == "sefse") {
        //think what to do here like prompt a form or something
        ShowFullName.text="Love";
    } 
    else {

        string sqlitequery = "SELECT FullName,Wins,Loss FROM `Player` WHERE           Username='{0}' AND Password ='{1}'";
        sqlitequery = string.Format (sqlitequery, usernameforsignin,  passwordforsingin);

        string conn = "Data  Source=C://Users//Usman//Desktop//GameProject10.07//Assets//DatabaseLove"; 

        IDbConnection dbconn;

        dbconn = (IDbConnection) new SqliteConnection(conn);
        dbconn.Open();          
        IDbCommand dbcmd = dbconn.CreateCommand();
        dbcmd.CommandText = sqlitequery;
        IDataReader reader = dbcmd.ExecuteReader();

        if(reader.Read() == true)
        {
            isSignin=true;

            SignInCanvas.enabled=false;
            MainMenuCanvas.enabled=true;
            ShowFullName.text= reader.GetString(0); 
            TotalWinsData.text = reader.GetInt16(1).ToString();
            TotalLossedData.text = reader.GetInt16(2).ToString();
            PlayerStats.enabled=true;


        }
        else
        {

            TotalWinsData.text="MAera ";
        }

        reader.Close();

        dbconn.Close();


    }

}

当我出现时我点击了Start按钮。开始按钮的编码是。

public void StartGame()
{
    ShowFullName.text= "I'm there";

   Application.LoadLevel (1);

}

它显示ShowFullName值,但卡在Apllication.laodlevel (1);上。 我该怎么办? 在登录游戏开始之前没有任何问题我现在该怎么办?

0 个答案:

没有答案