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 /
  • Help Room /
avatar image
0
Question by IronGirl · Aug 31, 2015 at 11:02 AM · unity 5google play games

save/load Data to Google Play games

Hello;

I m developing an android Game . the game uses Google Games Services. I can successfully sign in and show achievement and leaderboard. My first problem now when i use the saved Services, I have for exemple a public float Coins, is it possible to save it to the Cloud . I want to save some variable to the Google Cloud, when the player open my games and when the player close the game, save these variable to the cloud. Is it possible and how can i do that. there isn't documentation to explain that. Can you help please. Thanks a lot

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
1

Answer by sethuraj · Aug 31, 2015 at 11:12 AM

Yes its possible.Google Play Game services allows cloud data save.You can save anything converted to a binary (bytes[]) data.If you are using the play games plugin provided by Google in GitHub,everything is explained in detail there. https://github.com/playgameservices/play-games-plugin-for-unity

The plugin should be initialized with save game feature enabled

 PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
         // enables saving game progress.
         .EnableSavedGames()
         .Build();
     PlayGamesPlatform.InitializeInstance(config);

Check for opening and saving games section under 'Saving Game State to the Cloud' .

Comment
Add comment · Show 6 · 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 IronGirl · Aug 31, 2015 at 05:21 PM 0
Share

Hello sethuraj, Thanks for your answer , imagine if i have a public float Coins , how can i convert this variable to binary(bytes[]) and how can i save it to the cloud.Thanks again

avatar image sethuraj · Sep 01, 2015 at 04:30 AM 0
Share

@IronGirl A coin count will be always an integer.So there is no need to use a float to denote the coin count

 //The variable which holds the coin count
 public int Coins;
 
 //Convert the coin count integer to a byte array
 byte[] CoinData = BitConverter.GetBytes( Coins);

You can then write the value in 'CoinData' to cloud.Please read through this documentation for using play games services.Its very simple to understand

https://github.com/playgameservices/play-games-plugin-for-unity

avatar image $$anonymous$$ · Oct 08, 2015 at 10:31 PM 0
Share

Could you share the solution to save the coins?

avatar image graiderzs · Jan 14, 2016 at 07:30 AM 0
Share

@sethuraj Its too hard for me to understand =(

avatar image Nidhii · May 12, 2016 at 09:52 AM 0
Share

@sethuraj @IronGirl I am saving gems in my game using same process. But it opens a popup showing previous saves. Any way I can bypass that? Or using cloud method in this scenario is wrong. (In my Game, Player buy gems & I want to use some secure methods to save it on cloud)

Please answer my question at http://answers.unity3d.com/questions/1185506/saving-coins-online-after-in-app-purchase.html Thanks :(

Show more comments
avatar image
0

Answer by google_play_service_dev · Oct 02, 2016 at 02:45 AM

google play service api support save data with snapshot api. this is a code show how to save data. Game Snapshot

Display saved snapshot with default ui

GoogleGame.Instance().showSnapshots("saved games", true, true, 10); Save Game State with google play snapshot api.open snapshot first

GoogleGame.Instance().openSnapshot("firstgamesnap", true, GameConst.RESOLUTION_POLICY_MOST_RECENTLY_MODIFIED); and then write snapshot after event onOpenSnapshotResult,snapshotfilePath is a image path,the second param is your game data

GoogleGame.Instance().writeSnapshot(snapshotfilePath, System.Text.Encoding.UTF8.GetBytes("{'score':20}")); open a snapshot first and then get you saved data

GoogleGame.Instance().openSnapshot("firstgamesnap", true, GameConst.RESOLUTION_POLICY_MOST_RECENTLY_MODIFIED); after open success

byte[] gamedata=GoogleGame.Instance().readSnapshot();

https://github.com/unity-plugins/google-play-game-service-unity-plugin/wiki/google--Play-Game-Service-unity-plugin-Tutorial

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

36 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

Related Questions

Google Play Services Login isn't working 0 Answers

Google play services crash on start 2 Answers

How to get an access token with the OAuth 2.0 in the Unity Android Application? 1 Answer

CommandInvokationFailure: Failed to re-package resources 0 Answers

HELPPPPP Please :( CommandInvolkationFailure 0 Answers


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