Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by oliver-jones · May 30, 2014 at 10:28 AM · objectupdatepluginparse

Parse Plugin - Update Object Doesn't Update

I'm trying to update my score on Parse following the tutorial. Every time I try and update it - it just creates a new entry, meaning the player now has two scores. Then I update again, then the user has three scores, etc. The tutorial says this:

 // Create the object.
 var gameScore = new ParseObject("GameScore")
 {
     { "score", 1337 },
     { "playerName", "Sean Plott" },
     { "cheatMode", false },
     { "skills", new List<string> { "pwnage", "flying" } },
 };
 gameScore.SaveAsync().ContinueWith(t =>
 {
     // Now let's update it with some new data.  In this case, only cheatMode
     // and score will get sent to the cloud.  playerName hasn't changed.
     gameScore["cheatMode"] = true;
     gameScore["score"] = 1338;
     gameScore.SaveAsync();
 });

I assume it creates a new one is because this is all called when updating the score, meaning a new 'gameScore' is created too. But if I remove '`var gameScore = new ParseObject("GameScore")`' I get an error saying 'gameScore doesnt exist in current context'. So I need to define it - but if I do, it will just create a new Object, which completely defeats the purpose of this.

What am I missing here? Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by supernat · May 30, 2014 at 04:16 PM

When you say new ParseObject("GameScore"), it creates a new row entry in the GameScore class (table). If you want to update an existing one, you'll need to first submit a query (see the docs) then use the resulting ParseObject returned from the query (or a list of them), and set the key/value pairs from that. In the example above, if you just want to have a single row for the duration of your game (i.e. add a new row for every game), you can just say "var gameScore = new ParseObject("GameScore") in a script's Awake or Start method, and then update the key/value pairs whenever you want, calling SaveAsync() afterwards.

You only need the lambda expression when you want to do something extra after the async call is made. So really the example they give (the one posted here) is not very useful. You create an entry, set some values, then when it's done loading to the server, you set more values and send it again. It would make more sense to display a modal popup when you start saving async and then remove the popup when the operation is complete, or any other number of things.

By the way, if you use parse analytics or push notifications for mobile, they simply don't work with the Parse Unity plugin, and you have to implement them natively on the mobile. Just FYI.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bhatiarohan156 · Dec 15, 2015 at 07:31 AM 0
Share

PARSE PUSH NOW WOR$$anonymous$$S WITH PARSE UNITY PLUGIN. we just have to add ParsePush.jar to the plugin/android folder. ParsePush.jar can be found in PasePush example unity project.

avatar image
0

Answer by Trung PV · Jan 02, 2016 at 08:39 AM

I'm late for the party, but in case someone stumble upon this problem, here is what I did:

// Retrive the ParseObject in Start(); query = ParseObject.GetQuery ("HighScore"); query.GetAsync("YourObjectId").ContinueWith(t => { scoreObj = t.Result; });


// At somewhere you want to update the value scoreObj.SaveAsync().ContinueWith(t => { scoreObj["score"] = 5; scoreObj.SaveAsync(); });

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Vive HMD tracking does not work 2 Answers

Webplayer Engine Version 7 Answers

Parse Online Storage fails to communicate -1 Answers

How to destroy in an amount of time 1 Answer

using unity string plugin webcam 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges