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

have error on my database script

$
0
0
i have some trouble on my program it error "NullReferenceException: Object reference not set to an instance of an object MapLock_Chapter1.Start () (at Assets/Script/MapLock_Chapter1.js:28)" this is my code that error #pragma strict import System.Data; import Mono.Data.SqliteClient; private var connection : String; private var dbcon : IDbConnection; private var dbcmd : IDbCommand; private var reader : IDataReader; var nextLevel:String; var texturelock : Texture2D; var textureunlock : Texture2D; var QuitButton:boolean; var chapterUnlocked : boolean; var chapterlocked : boolean; var needitem:GUIText; var text:String = " Gather 100 Diamond to unlock "; function Start(){ connection = "URI=file:" + "23.s3db"; // we set the connection to our database dbcon = new SqliteConnection(connection); dbcmd = dbcon.CreateCommand(); // create empty command var cmdSql = "SELECT diamond FROM test"; dbcmd.CommandText = cmdSql; // fill the command dbcon.Open(); reader = dbcmd.ExecuteReader(); // execute command which returns a reader while( reader.Read() ) { var pdiamond : int = int.Parse(reader["diamond"].ToString()); chapterUnlocked = ( pdiamond > 99); chapterlocked = ( pdiamond < 100); print(pdiamond); } } function Update () { } function OnGUI () { if (chapterlocked) { guiTexture.texture = texturelock; needitem.text = text; } if (chapterUnlocked) { guiTexture.texture = textureunlock; } } function OnMouseUp () { if(QuitButton) { Application.Quit(); } else { Application.LoadLevel(nextLevel); } } plz help me thank you.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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