sqlite - How to execute a C# code in Unity 3D? -


this simple question, bit hard unity newbie me.

i have coded this. (see below.)

using unityengine; using system.collections; using mono.data.sqlite;  using system.data;  using system;  public class newbehaviourscript1 : monobehaviour {     // use initialization     void start () {      string conn = "uri=file:" + application.datapath + "/sensor.sqlite"; //path database.     idbconnection dbconn;     dbconn = (idbconnection) new sqliteconnection(conn);     dbconn.open(); //open connection database.     idbcommand dbcmd = dbconn.createcommand();      string sqlquery = "select x1 " + "from sport";     dbcmd.commandtext = sqlquery;     idatareader reader = dbcmd.executereader();      while (reader.read())     {         int value = reader.getint32(0);         string name = reader.getstring(1);         int rand = reader.getint32(2);     }      reader.close();     reader = null;     dbcmd.dispose();     dbcmd = null;     dbconn.close();     dbconn = null;  } 

}

and saved.

however, not know how execute this. idea? thank you.

you need associate script object (you can use "empty object") , run project.

as posted in comments, best starting point. http://docs.unity3d.com/manual/creatingandusingscripts.html

as quick primer:

start() ran once upon loading (or "creating" object -- done automatically if add object via gui). update() ran on every frame render , done fast possible. higher frame rate more executions.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -