Attached is the package that will save and load from MySQL included is a PDF that describes the process of setting up MySQL, adding a table with fields, and adding a view to read from.
Original Release Date 10/10/2010
Updated 10/12/2010
Package now includes both the completed JS and C# scripts to make this work, the PDF is also updated with the JS code.
Updated 2/10/2012
Package updated since the Libraries folder I had contained the DLL’s that worked in 3.4 but not in 3.5, instead they are required now to be in the Plugins folder which really is not a bug but how the system should have originally worked, they simply refined how they truly look for unmanaged libraries.
Well, the project is made in U3, so you probably can’t open it in U2.6, the files needed will be the same ones, you just have to pull the ones out of the Unity Editor folders for the local files from
C:\Program Files\Unity\Editor\Data\Mono\lib\mono\unity System.Data.dll and System.Drawing.dll
The other file is located in:
C:\Program Files\MySQL\MySQL Connector Net 6.2.4\Assemblies MySql.Data.dll
Just make sure you get and download the connector for .net
No because Unity does not allow the MySQL library to be deployed with the package.
I plan on deploying an updated document and package this weekend, but this only works in Mac builds and Windows builds, not web player, not andriod, not iphone, nothing else at the moment until Unity loosens up the security model some, which is highly unlikely.
Sure you really want to make the database globally accessable? (required for mysql to talk to the database)
Its normal that you talk to PHP / ASP.NET layers inbetween that provide you with the informations you need (which can be done through WWW)
Say your database has user info (username, address, char name, CC?, etc)
Do you really want a web player to be able to access that data? Databases usually don’t have very specific ‘permissions’ settings, and you need to have a very good understanding of database design in order to design a system that was ‘safe’ for global access.
For example, at the minimum to set up an ‘authentication’ system, you would need to set up a internally defined procedure in the database’s script language. Then you’d have to set very narrow permissions so that procedure is the only thing visible from the global connection. Then you’d have to consider that most ‘community’ versions of databases tend to not feel OK with 50+ active connections, so you’d hit that threshold pretty quickly with even a mildly successful game.
I would be interested to know how this works. I noticed in the example code that there are some for() loops and the assigning of variables to object variables. I wonder why is this needed, and why couldn’t I just write a simple query statement (SELECT * FROM characters WHERE char_id = ?ID) (I’m assuming that the ? in front of the ID informs the processor this is a variable?)
Thanks.
Seems like a lot more work than just writing a PHP script to process the query and then transfer that to an array for JavaScript to parse though.
I had problems with saving and loading, it came up with some funky errors:
1 : Items in collection : 2
2 : Something about iddemo_table doesn’t have default value at MYSQL really long stuff
Get anyone the mysql dll’s working under unityscript? I can use them with c#, but get only error’s (Namespace ‘MySql.Data.MySqlClient’ not found, maybe you forgot to add an assembly reference? or BCE0005: Unknown identifier: ‘MySql’.)
Thats blurp, its no virus. pushed it through kaspersky and ESET32, no hit, so its pretty surely a false positiv of some half arsed freeware protection (avira or payed viruses like McAfee / norton that claim to be good yet lack enough and even spread fake virus / worms that only they detect)
It appears that the latest version of Unity has removed the native import of libraries to an extent, more stripping I suppose, this was working in prior versions of Unity 3, but the new public beta, the JS doesn’t work, looks like a regression bug to me. I know the C# version still works but even though the DLL is in the right place from the package, Unity 3.5 public beta does not work with it an Unity Script.
EDIT:
Re-Download the package that or create a folder called Plugins in your asset folder and move all DLL’s that are in the Libraries folder to the Plugins folder, wabam, should now work. All these itterations later and they make a change where the unmanaged AND managed are now required to be in the Plugins folder, it used to be that you could put them in your own folders exclusive of the Plugins folder to the bug was really that the unmanaged AND managed libraries were allowed to be anywhere and they fixed that. All DLL’s need to be inthe Plugins folder it looks like for 3.5