c# - get_version can only be called from the main thread -


this question has answer here:

so using parse.com(a backhand database provider, made facebook) unity project. got stuck serious problem. here explanation;

as long throw out synchronization codes game works fine need in order make player sync data server.

so here error im getting:

get_version can called main thread. constructors , field initializers executed loading thread when loading scene. don't use function in constructor or field initializers, instead move initialization code awake or start function.

and here user.cs code:

using unityengine; using system.collections; using system.threading; using parse;  public class user : monobehaviour {      public bool isauthenticated = false;     public string username = null;     public int level;     public int exp;     public int money;     public golobby golobby;     public sync sync;     public bool isgolobbyenabled = false;  public void loginuser(string username, string password)     {          var query = parseobject.getquery("member")             .whereequalto("username", username)             .whereequalto("password", password);         query.firstordefaultasync().continuewith(t =>                                        {             parseobject result = t.result;             //print (result);             string playername = result.get<string>("username");             string playerpassword = result.get<string>("password");             int playerlevel = result.get<int>("level");             int playerexp = result.get<int>("experience");             int playermoney = result.get<int>("money");             isauthenticated = true;             username = playername;             money = playermoney;             exp = playerexp;             sync.synctoserver (username, level, exp, money);             isgolobbyenabled = true;             golobby();         });     } 

here sync.cs code:

using unityengine; using system.collections; using parse;  public class sync : monobehaviour {      public void synctoserver (string username, int level, int exp, int money)     {         var query2 = parseobject.getquery ("member")             .whereequalto ("username", username);         query2.firstasync ().continuewith (t =>                                            {             parseobject obj = t.result;             debug.log (obj.objectid); //works fine             obj["level"] = level;             obj["experience"] = exp;             obj["money"] = money;             obj.saveasync();         });     } } 

this might related unity5 , latest parse right..? unity5+old parse not giving issue, unity5+new parse(pushnotifications) giving error. have opened issue ticket parse sdk.

https://developers.facebook.com/bugs/390409301154954


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -