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 SoundPuppy · Apr 23, 2016 at 04:39 PM · c#binaryformatterbinarybinarywriter

Save system not working

@Mavina

im getting a error for data.text please help

save system:

 using UnityEngine;
 using System.Collections;
 using System;
 using System.Runtime.Serialization.Formatters.Binary;
 using System.IO;
 using UnityEngine.UI;
 public class SaveSystem : MonoBehaviour {
     
     public static Text charText;
     public static int money;
     public static int cakeMultiplier;
     public static Text TextMoney;
     public static int CakesUpgrades;
     public static Text Cakes;
     public static int DVDSUpgrades;
     public static Text DVDS;
     public static int dvdMultiplier;
     public static int CDSUpgrades;
     public static Text CDS;
     public static int cdsMultiplier;
     public static int VideoGamesUpgrades;
     public static Text VideoGames;
     public static int videogamesMultiplier;
     
     public void SaveState()
     {
         BinaryFormatter bf = new BinaryFormatter();
         FileStream file = File.Create(Application.persistentDataPath + "/PlayerData.dat");
         
         PlayerData data = new PlayerData();
         
        
         data.text = UIInputField.charText.text;
         data.money = UpgradeCakes.money;
         data.cakeMultiplier = UpgradeCakes.cakeMultiplier;
         data.TextMoney = UpgradeCakes.TextMoney.text;
         data.Cakes = UpgradeCakes.Cakes.text;
         data.CakesUpgrades = UpgradeCakes.CakesUpgrades;
         data.DVDSUpgrades = UpgradeCakes.DVDSUpgrades;
         data.DVDS = UpgradeCakes.DVDS.text;
         data.dvdMultiplier = UpgradeCakes.dvdMultiplier;
         data.CDSUpgrades = UpgradeCakes.CDSUpgrades;
         data.CDS = UpgradeCakes.CDS.text;
         data.cdsMultiplier = UpgradeCakes.cdsMultiplier;
         data.VideoGamesUpgrades = UpgradeCakes.VideoGamesUpgrades;
         data.VideoGames = UpgradeCakes.VideoGames.text;
         data.videogamesMultiplier = UpgradeCakes.videogamesMultiplier;
         
         bf.Serialize(file, data);
         file.Close();
     }
     
     public void LoadState()
     {
         if(File.Exists(Application.persistentDataPath + "/PlayerData.dat"))
         {
             BinaryFormatter bf = new BinaryFormatter();
             FileStream file = File.Open(Application.persistentDataPath + "/PlayerData.dat", FileMode.Open);
             PlayerData data = (PlayerData) bf.Deserialize(file);
             file.Close();
             
             
             UIInputField.charText.text = data.text;
             UpgradeCakes.money = data.money;
             UpgradeCakes.cakeMultiplier = data.cakeMultiplier;
             UpgradeCakes.TextMoney.text = data.TextMoney;
             UpgradeCakes.CakesUpgrades = data.CakesUpgrades;
             UpgradeCakes.Cakes.text = data.Cakes;
             UpgradeCakes.DVDSUpgrades = data.DVDSUpgrades;
             UpgradeCakes.DVDS.text = data.DVDS;
             UpgradeCakes.dvdMultiplier = data.dvdMultiplier;
             UpgradeCakes.CDSUpgrades =  data.CDSUpgrades;
             UpgradeCakes.CDS.text = data.CDS;
             UpgradeCakes.cdsMultiplier = data.cdsMultiplier;
             UpgradeCakes.VideoGamesUpgrades = data.VideoGamesUpgrades;
             UpgradeCakes.VideoGames.text = data.VideoGames;
             UpgradeCakes.videogamesMultiplier = data.videogamesMultiplier;
             
             
             
             
             
            
         }
     }
 }
 
  [Serializable]
  class PlayerData
  {
      public string charText;
     public int money;
     public int cakeMultiplier;
     public string TextMoney;
     public int CakesUpgrades;
     public string Cakes;
     public int DVDSUpgrades;
     public string DVDS;
     public int dvdMultiplier;
     public int CDSUpgrades;
     public string CDS;
     public int cdsMultiplier;
     public int VideoGamesUpgrades;
     public string VideoGames;
     public int videogamesMultiplier;
  }
 
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 jgodfrey · Apr 23, 2016 at 05:36 PM 0
Share

Please - do us (and yourself) a favor and at least attempt to provide enough info so that we can assist.

  • What is the actual error you're receiving?

  • Where in the above code does the error happen?

avatar image SoundPuppy jgodfrey · Apr 23, 2016 at 05:49 PM 0
Share

the data.text

avatar image jgodfrey SoundPuppy · Apr 24, 2016 at 12:15 AM 0
Share

You're unlikely to get any assistance if that's all the energy you can bother to put into providing useful information...

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by TBruce · Apr 24, 2016 at 11:52 PM

@SoundPuppy

Open your console window so that you can see all the errors and at a minimum copy them (if you do a print screen you will have an image which you will need to save to a file so that you can post it here). As @jgodfrey said you need to include complete error messages when (at run time or compile time) and where they are located (including line numbers - that's why formatting is important).

Comment
Add comment · Show 1 · 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 SoundPuppy · Apr 30, 2016 at 10:06 AM 0
Share

sorry it doesnt matter i fixed it

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

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

Using System.Runtime.Serialization.Formatters.Binary for Windows Store Apps 3 Answers

Editor freezing when saving in binary 1 Answer

Do a smaller object type than int exists? 2 Answers

How to add a new data to existing Binary file without erase the previous data? 0 Answers

Convert int to binary 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