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 DemonQueenGames · Jun 28, 2015 at 12:02 PM · playerprefsbooleanloadingsavingdatetime

PlayerPrefs not saving mission info at all.

Hello I know there are questions like this out there but based on everything I have seen I am not doing anything incorrect however while all the info is being hit correctly checked by both debug statements and stepping threw the code with the debugger when i go to load its as if nothing saved it all comes back to the default value. I have read many answers and I have gone threw unity's forums stack overflow and any piece of information I could find but I just can't seem to get this to work. I have other things in the program saving correctly with no issues I honestly am just not finding where I am going wrong and my employer is getting impatient. I need another set of eyes please any help would be greatly appreciated I have included the functions being called as a whole but I can provide more if needed.

Thanks;

 public void SaveMission(string airlineName){
 
         Debug.Log("Saving mission " +airlineName +  MissionName+"CompletedTime "+TimeCompleted.ToString());
         PlayerPrefs.SetString(airlineName +MissionName+"CompletedTime",TimeCompleted.ToString());
 
         //Save if the mission was completed
         if(IsMissionCompleted){
             Debug.Log("Saving mission as complete");
             PlayerPrefs.SetInt(airlineName +  MissionName+"IsComplete",1);}
         else{
             Debug.Log("Saving mission as incomplete");
             PlayerPrefs.SetInt(airlineName + MissionName+"IsComplete",0);}
 
         Debug.Log(PlayerPrefs.GetInt(airlineName + MissionName+"IsComplete"));
 
         PlayerPrefs.Save();
     }
      
     public void LoadMission(string airlineName){
         //load the time that the mission was completed
         Debug.Log("Loading mission " +airlineName +MissionName+"CompletedTime "+TimeCompleted.ToString());
         string tempdate = PlayerPrefs.GetString(airlineName +MissionName+"CompletedTime");
         //load if the mission was completed
         int tempbool = PlayerPrefs.GetInt(airlineName + MissionName+"IsComplete");
 
         //convert values to the proper type
         if(tempdate != ""){
         TimeCompleted = DateTime.Parse(tempdate);
         }
         else{TimeCompleted = DateTime.MinValue;}
         Debug.Log(tempbool.ToString());
 
         if(tempbool == 1){
             IsMissionCompleted = true;
         }
         else{
             IsMissionCompleted = false;
         }
 
 }
 

Comment
Add comment · Show 2
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 maccabbe · Jun 29, 2015 at 02:21 AM 0
Share

Your code seems to work, i tried the following and it printed out

"That AirlineSpace LaunchCompletedTime 6/28/2015 10:18:59 P$$anonymous$$"

"Saving mssion as complete"

"1"

"Loading mission That AirlineSpace LaunchCompletedTime 6/28/2015 10:18:59 P$$anonymous$$"

"1"

 using UnityEngine;
 using System;
 public class NewBehaviourScript : $$anonymous$$onoBehaviour {
     string $$anonymous$$issionName="Space Launch";
     bool Is$$anonymous$$issionCompleted=true;
     DateTime TimeCompleted=DateTime.Now;
     void Start () {
         Save$$anonymous$$ission("That Airline");
         Load$$anonymous$$ission("That Airline");
     }
 
     public void Save$$anonymous$$ission(string airlineName){ 
         Debug.Log("Saving mission " +airlineName +  $$anonymous$$issionName+"CompletedTime "+TimeCompleted.ToString());
         PlayerPrefs.SetString(airlineName +$$anonymous$$issionName+"CompletedTime",TimeCompleted.ToString());
  
         //Save if the mission was completed
         if(Is$$anonymous$$issionCompleted){
             Debug.Log("Saving mission as complete");
             PlayerPrefs.SetInt(airlineName +  $$anonymous$$issionName+"IsComplete",1);}
         else{
             Debug.Log("Saving mission as incomplete");
             PlayerPrefs.SetInt(airlineName + $$anonymous$$issionName+"IsComplete",0);
         }
  
         Debug.Log(PlayerPrefs.GetInt(airlineName + $$anonymous$$issionName+"IsComplete"));
  
         PlayerPrefs.Save();
     }
 
     public void Load$$anonymous$$ission(string airlineName) {
         //load the time that the mission was completed
         Debug.Log("Loading mission "+airlineName+$$anonymous$$issionName+"CompletedTime "+TimeCompleted.ToString());
         string tempdate=PlayerPrefs.GetString(airlineName+$$anonymous$$issionName+"CompletedTime");
         //load if the mission was completed
         int tempbool=PlayerPrefs.GetInt(airlineName+$$anonymous$$issionName+"IsComplete");
 
         //convert values to the proper type
         if(tempdate!="") {
             TimeCompleted=DateTime.Parse(tempdate);
         }
         else { TimeCompleted=DateTime.$$anonymous$$inValue; }
         Debug.Log(tempbool.ToString());
 
         if(tempbool==1) {
             Is$$anonymous$$issionCompleted=true;
         }
         else {
             Is$$anonymous$$issionCompleted=false;
         }
     }
 }
avatar image DemonQueenGames · Jun 29, 2015 at 02:55 AM 0
Share

Thank you at least I know I am not going crazy lol but I still need to figure out why its not working for me I will have to look somewhere else like in the function calls thank you for your help! and if I find out what the issue is I will post it.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Saving and load from player prefs in Unity3D on mobile devices?? 0 Answers

Problems with Playerprefs script 1 Answer

Saving Scenes and loading GameObjects? 4 Answers

How to efficiently hand out rewards based on the level that the player completed? 3 Answers

Saving & Loading the scene (or at least one array) via Javascript 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