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
0
Question by rakuzas · Dec 09, 2015 at 12:57 PM · playerprefsgoogle play gamessaveloadplayer settings

How to save playerprefs data into Google PlayGames (unity) plugin?

Hello,

I successfully configured and using the login and Save Load feature in Google PlayGames plugin with the guide in the github of the plugin.. Then, recently when I'm uninstall, clean data with Cleaner apps and fresh install my game.. I press Load Button and then press Play.. Sadly, there is no data loaded.. My coins in game supposed to be 30 started from zero.. So i'm know that I'm missing something.. Then I tried to edit this CubicPilot GameProgress.cs.. Then I got error.. Hope can guide me.. Thank you in advance..

Information :

  • Unity 5.2

  • Google PlayGames plugin 0.9.27 (unity)

  • My game using own playerprefs and coinsPlayer is the INT name in there..

Error Code here :

 IndexOutOfRangeException: Array index is out of range.
 CubicPilot.GameLogic.LevelProgress.SetFromString (System.String s) (at Assets/CubicPilot/GameLogic/LevelProgress.cs:96)
 CubicPilot.GameLogic.GameProgress.FromString (System.String s) (at Assets/CubicPilot/GameLogic/GameProgress.cs:156)
 CubicPilot.GameLogic.GameProgress.LoadFromDisk () (at Assets/CubicPilot/GameLogic/GameProgress.cs:82)
 CubicPilot.GameLogic.GameManager..ctor () (at Assets/CubicPilot/GameLogic/GameManager.cs:71)
 CubicPilot.GameLogic.GameManager..cctor ()
 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for CubicPilot.GameLogic.GameManager
 CubicPilot.Gui.MainMenuEvents.Start () (at Assets/CubicPilot/Gui/MainMenuEvents.cs:50)

Here is the line of error :

 mCoins = Convert.ToInt32(p[3]);

Here is the code.. But somehow error..

 /*
  * Copyright (C) 2014 Google Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 namespace CubicPilot.GameLogic
 {
     using System;
     using UnityEngine;
 
     public class LevelProgress
     {
         private int mScore, mStars, mCoins;
 
         public int Score
         {
             get
             {
                 return mScore;
             }
             set
             {
                 mScore = value;
             }
         }
 
         public int Stars
         {
             get
             {
                 return mStars;
             }
             set
             {
                 mStars = value;
             }
         }
 
         public int coinsPlayer 
         {
             get 
             {
                 return mCoins;
             }
             set 
             {
                 mCoins = value;
             }
         }
 
         public bool Cleared
         {
             get
             {
                 return mScore > 0;
             }
         }
 
         public LevelProgress()
         {
             mScore = mStars = mCoins = 0;
         }
 
         public LevelProgress(int score, int stars, int coinsPlayer)
         {
             mScore = score;
             mStars = stars;
             mCoins = coinsPlayer;
         }
 
         public override string ToString()
         {
             return string.Format("LP {0} {1} {2}", Score, Stars, coinsPlayer);
         }
 
         public void SetFromString(string s)
         {
             string[] p = s.Split(new char[] { ' ' });
             if (p.Length != 3 || !p[0].Equals("LP"))
             {
                 Debug.LogError("Failed to parse level progress from: " + s);
                 mStars = mScore = mCoins = 0;
             }
             mScore = Convert.ToInt32(p[1]);
             mStars = Convert.ToInt32(p[2]);
             mCoins = Convert.ToInt32(p[3]);
         }
 
         public static LevelProgress FromString(string s)
         {
             LevelProgress lp = new LevelProgress();
             lp.SetFromString(s);
             return lp;
         }
 
         public bool MergeWith(LevelProgress other)
         {
             bool modified = false;
             if (other.mScore > mScore) {
                 mScore = other.mScore;
                 modified = true;
             }
             if (other.mStars > mStars) {
                 mStars = other.mStars;
                 modified = true;
             }
             if (other.mCoins > mCoins) {
                 mCoins = other.mCoins;
                 modified = true;
             }
             return modified;
         }
     }
 }
 










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

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Google play services saved games highscore error 0 Answers

PlayerPrefs.GetString not saving past values 0 Answers

PlayerPrefs string variables 1 Answer

Save Time Button Settings in Player Prefs 2 Answers

PlayerPrefs Script Problem 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