So I have an app that's using Parse. I'm able to create new ParseObjects with no problem, as well as query for saved ParseObjects. However, whenever I try to update an existing ParseObject I've queried for, I get the following error:
"get_bundleIdentifier can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function."
Now I've found some people getting similar errors, with "get_bundleIdentifier" being the difference, and I think it has to do with not being run from the "main thread", but I don't know how to affect that. I've tried the same code in a coroutine as suggested here and I get the same error.
I'm using Parse Version 1.6.0 and Unity Pro 5.1.2. Here is my code:
using UnityEngine;
using System.Collections;
using Parse;
using System.Threading.Tasks;
public class SimpleParseScript : MonoBehaviour {
// Use this for initialization
void Start () {
var query = ParseObject.GetQuery("ChallengeScores") // query to parse to find scores and whos turn
.WhereEqualTo("challengeID", 20307271925313064);
query.FirstAsync().ContinueWith(t =>
{
ParseObject gameStatus = t.Result;
print (gameStatus.ObjectId); // print queried ParseObject ObjectId - works fine
gameStatus["turnsTaken"] = 100;
Task saveTask = gameStatus.SaveAsync();
});
}
}
Now, if I comment out "gameStatus["turnsTaken"] = 100;", then try to save it, it runs through just fine, though nothing gets saved for obvious reasons.
Anyone got a clue? The parse documentation right here says it should be as simple as declaring it and saving it again after querying, but no go.
Thank you for your time and patience.