I am using Unity and Parse.com for my game development. I am trying to figure out I retrieve the objectId right after save. I have tried this:
ParseObject myGame = new ParseObject("Games");
myGame["score"] = 223;
myGame["playerName"] = "Michael";
Task saveTask = myGame.SaveAsync().ContinueWith(t => {
ParseObject theObject = t.Result;
string newObjectId = theObject.objectId;
});
I get an error on the t.Result saying:
Type `System.Threading.Tasks.Task' does not contain a definition for `Result' and no
extension method `Result' of type `System.Threading.Tasks.Task' could be found (are
you missing a using directive or an assembly reference?)
Can this be done in this way or another.
any help is appreciated and thanks in advance :-)
I was also having problems with retrieving the newly created ObjectId. After a few hours (and a lot of searching) I was able to get the below code to work:
public static async Task<string> CreateNewGame()
{
string newObjectId = null;
ParseObject myGame = new ParseObject("Games");
myGame["score"] = 223;
myGame["playerName"] = "Michael";
await myGame.SaveAsync().ContinueWith(
t =>
{
newObjectId = myGame.ObjectId;
});
return newObjectId;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With