Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by kabumere · Dec 08, 2016 at 01:22 AM · CloudScriptapisPlayer DataAccount Management

Saving data in Unity on Pause/Quit/Lose Focus

Background (you can skip below to TLDR) as this portion isn't really necessary to answer the question):

Alright so I'm implementing my saving functionality and my apps are being built using Unity.

Although I do not have all the save functionality completed, I'm planning on having critical items like currency being updated through CloudScripts where I can safely put my security checks (if reason for gem increase == anything other than 'store', then values above 1000 are not realistic/allowed, etc) and non-critical items like the Player class serialized JSON (minus currency, stats, etc) being updated through regular PlayerData calls.

There's specific points in my game where I will plan to call these methods like updating currencies after ever run session (it's an infinite runner) or updating currencies after every shop purchase, but I was thinking, if a user or the OS force closes an app, where should I save the data?

I understand OnApplicationQuit isn't guaranteed to be called on some platforms with Unity, so OnApplicationPause seems like the next best thing. But will putting a call to PlayFab in OnApplicationPause issue API calls too frequently? Since OnApplicationPause(true) can be called whenever a person answers a call, goes to their home screen, puts the app out of focus, and OnApplicationPause(false) is called whenever we resume. Currencies probably won't be updated here as the only time they should change are strategic points I mentioned earlier. However some PlayerData key-value pairs will need to be saved on quit/pause.

TLDR)

1) For anyone familiar with Unity, in the case of my app losing focus or being quit, I need to know the best place to issue calls to PlayFab for saving my game data (OnApplicationQuit / OnApplicationPause / etc).

2) Would I go over my allotted amount of API calls too quickly putting calls in OnApplicationPause?

3) Is there a page that tells us clear cut the limits we have each month, or is the only limit being under a certain amount of MAU each month like GameSparks?

Comment

People who like this

0 Show 0
10 |1200 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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Dec 08, 2016 at 01:29 AM

The limits for the service are the ones you see in your Settings tab (for total bytes, number of keys, etc.) plus a rate limit for calls, to prevent a title from spamming the service and impacting performance. You should aim to have your call rate be as low as you can make it for multiple reasons. One is, of course, that we'd prefer to keep costs as low as possible so that we can continue to offer the free service, and keep our prices for upgrades and enterprise contracts as low as possible. But another is that frequent calls from a mobile device will drain the battery more quickly - and you might be surprised how irritable that can make people (which is to say, it will cause some abandonment). If you're making a call every few minutes to save, that's not a problem. But yes,we'd definitely recommend saving some data locally, as in addition to not being able to guarantee that you'll get a quit or pause call, you have to account for the fact that even if you do, the player might not have a connection at that point (in a tunnel, on a plane, etc.).

Comment

People who like this

0 Show 2 · Share
10 |1200 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 kabumere · Dec 08, 2016 at 01:37 AM -1
Share

Whenever they try to save and they no longer have a connection at that point I switch them to offline mode (which a player can only be in for up to 24hrs and it puts caps on the amount of currencies and items one can gain). When offline is on I save stuff locally.

But it's only if we get an error from PlayFab that I have the game switch to offline mode and save things locally until a connection is found.

My question was more focused on the cases where OnApplicationXXX is called, and the app suddenly quits before the call to PlayFab is even made/in the middle of the call (so my app can't receive the response). I was looking for what to do in these particular situations.

Also, on average by your statistics, about how many monthly users can one acquire before they start to go over the monthly limits?

avatar image Brendan ♦♦ kabumere · Dec 08, 2016 at 01:40 AM 0
Share

There is no limit on the number of users - limits are per user.

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.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Converting PlayFab Info to Player Object 2 Answers

    Converting playfab login system to linked steam system? 1 Answer

    AvatarUrl hidden limit: ImageUrl cannot exceed 200 characters 3 Answers

    The name 'SteamName' does not exist in the current context 1 Answer

    Using Custom Tags with Email verification rule 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges