|
I cannot seem any reference on how to go about spawning gameobjects from a sql/php backend using data retrieved using the WWW set. I cant seem to find any kind of reference in regards to this anywhere. Im trying to pull x,y,z from the sql using php and the spawning the prefab for the player at the position. I need to be able ot parse the data out of the returned data and then spawn the gameobject based on the data. Any thoughts/references on this would be greatly appreciated. Thank you!
(comments are locked)
|
|
You can use WWW to open any url you want, including your typical get parameters (e.g. http://myserver.com/?action=getData) www.data will contain the received data as a string. So you can write you own php code, that will return the reqired data in a format that you can easily parse. To parse the returned data you can use the standard .net string features, or you return xml and use .net's xml parsing functions. Thank you very much for a prompt reply. It has put me in the right direction. Would you have to have any links to spawning dynamic gameobjects based on the data received from the database?
Apr 06 '10 at 09:49 PM
Om3n
Do you mean loading the gameobjects from a distant server, or just spawning a prefab? For loadin look up asset streaming in the manual. For spawning prefabs look at GameObject.Instantiate() and Resources.Load
Apr 07 '10 at 07:24 AM
StephanK
I meant loading the gameobjects with data received with info from the www data stream. ie: client logs in & queries the db then spawns objects based on that query. I will start with asset streaming to see if it leads me anywhere, Thank you again.
Apr 07 '10 at 02:45 PM
Om3n
(comments are locked)
|
|
This is how i ended up doing it, hopefully it can serve as an example for somone else =)
{ // show the progress window showProgress=true;
(comments are locked)
|
|
Question: Can i use this way to read fetched data from php/MYSQL Db. code in my unity .js file.var hs_get : WWW = new WWW (url); yield hs_get; var newdata = hs_data.data; . . . does this mean , "newdata" has all the attributes as in the database table fetched from DB using PHP? reply to me : sandeepsebol@gmail.com
(comments are locked)
|
|
Please note. This might fail strangely and silently. Check if there is difference between receiving hard coded and dynamic data using this php code:
(comments are locked)
|

instead of renaming your question (solved), please click the accept button on the answer that sovled your question. Thanks! Lucas
Ditto. Let's try to keep it tidy.