Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by starikcetin · Oct 29, 2015 at 03:46 PM · c#androidgoogle playgoogle play games

GPGS - How to check if a Saved Game file exists?

I'm planning to use Google Play Game Services plugin's "Saved Games" feature for my online game to save in-game currency. The file name will be an hard-coded constant for everybody. So, how can i check if a Saved Game file exists or not?

Comment
Add comment · Show 3
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 starikcetin · Oct 29, 2015 at 05:19 PM 0
Share

bump. still looking for solution.

avatar image Cherno · Oct 29, 2015 at 05:38 PM 0
Share

Sound more like a question specific to GPGS rather than C# or Unity. For System.IO, there is File.Exists(), so I assume there must be something similar.

avatar image starikcetin Cherno · Oct 29, 2015 at 05:44 PM 1
Share

Well, their unity plugin's documentation is very poor, actually they should have thought this, unity is a huge community. Anyways, i'm trying to figure this out by fetching all saved games and checking the returning list.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by CyanSprite · Aug 17, 2016 at 05:53 AM

@s-at-c have you tried:

 private static void OnSavedGameDataRead(SavedGameRequestStatus status, byte[] data){
 
 
 bool fileNeverWritten = data.Length == 0;
 
 
 }

This works for me on first time setup type things, then I write data... If you are creating the save file, then not writing data and then checking it, I'm not sure if it will work, I will test soon and update you.

Comment
Add comment · Show 3 · 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 Blind56 · Aug 22, 2016 at 06:07 PM 0
Share

if there is no save file to read, how can this method be called? it doesn't go further than calling open method. checked that experimentally

avatar image ecv80 Blind56 · Nov 29, 2018 at 10:37 AM 0
Share

In Google game services cloud saving you always have to open a file before attempting to save. Apparently if you try to read it right after opening without even saving, the reading call succeeds and returns a 0 sized byte array.

avatar image ecv80 · Nov 29, 2018 at 10:34 AM 0
Share

I just tried this and it works. This is the correct answer. As for committing an update of size 0 and checking afterwards I didn't test it either and have no idea if this will work either.

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

40 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 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

Play Game Services not working with a published game 0 Answers

Google Play Services error 0 Answers

Unity Google Play Service Plugin Social.localUser.Authenticate(…) App Crash 1 Answer

Problem with Google Play Game Services: Invalid Classname 1 Answer

GPGS - How To Cancel Matchmaking Properly? 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