vendredi 18 décembre 2015

Sqlite in Unity

Here's my code working fine.Only Problm I'm facing is that when I'm logedIn it won't load my Level. Here's my code.

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();


    }

}

When I'm logedIn I click on the Start Button.Coding of start buttons is.

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

   Application.LoadLevel (1);

}

It shows the ShowFullName value but stuck on the Apllication.laodlevel (1);. What should I do. Before the loggingIn game starts without any problem what should I do now?

Aucun commentaire:

Enregistrer un commentaire