Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Disappearing Gameobject

$
0
0
i am making a word game in unity in which i have many game objects each gameobject name is a letter from A to Z. when i click on the object the letter appear on screen .when i made a word it compare it from dictionary either it is correct or not i want that if i made a correct word from the letters and click the button the gmaeobject containg those letters from which i made the word disappear here is the code: internal void ReadStudent(string filetoread,string tableName, string itemToSelect, string wCol, string wPar, string wValue){ //jsScript = Camera.main.GetComponent(); string connection = "Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" + filetoread; Debug.Log(connection); string sqlQuery = "SELECT word FROM "+ tableName + " WHERE " + wCol + " " + wPar + " '" + wValue + "'"; OdbcConnection con = new OdbcConnection(connection); OdbcCommand cmd = new OdbcCommand(sqlQuery,con); DataTable dt = new DataTable("dic"); try{ con.Open(); OdbcDataReader reader = cmd.ExecuteReader(); dt.Load(reader); reader.Close(); con.Close(); } catch (Exception ex){ //text = dt.Rows[3][1].ToString(); Debug.Log(ex.ToString()); } finally{ if (con.State!=ConnectionState.Closed){ con.Close(); } con.Dispose(); } if (dt.Rows.Count>0){ text = dt.Rows[0]["word"].ToString(); Debug.Log(text); Debug.Log (wValue); Debug.Log ("Correct"); for(int i=0; i<=wValue.Length;i++){ Debug.Log ("Enter"); if(wValue[i]==gameObject.name[i]){ Debug.Log ("Enter"); gameObject.SetActive (false); } } } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>