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
1
Question by Nick4 · Jun 23, 2014 at 11:14 AM · serializationbinaryformatterdeserializationio

EndOfStreamException : Failed to read past end of stream

 [Serializable]
 class LevelData
 {
     public Dictionary<Vector2, Level> levelButtonData;
 }

Alright. I have this class I'm trying to deserialize using BinaryFormatter. It was fine yesterday, I didn't get any exceptions or anything. I could simply serialize and and deserialize my class untill today I wanted to try again. It gave that exception I typed in the title section. And this line is the one that causes that exception:

 LevelData lvlData = (LevelData)formatter.Deserialize(file);

I haven't touched anything since yesterday. That's the weird thing.

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

1 Reply

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

Answer by Nick4 · Jul 10, 2014 at 09:03 PM

That's what happens when you deserialize a different file :)

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 hrobert · Jun 26, 2015 at 02:12 AM 0
Share

Can you explain a little bit more ? A got the same problem and keep struggling with this error message. Here the class i want to serialize (in fact I serialize a list of this class instances).

  using UnityEngine;
     using System.Collections;
     
     
     [System.Serializable]
     public class Action {
     
         
         string objective;   //position or target
     
         string target;
     
         string script;
     
         Vector2 position;
     
     
         public Action(string objective, string target)
         {
     
             this.objective = objective;
             this.target = target;
     
         }
     
     
         public Action(string objective, Vector2 position)
         {
     
             this.objective = objective;
             this.position = position;
             
         }
     
         public Vector2 getPosition()
         {
     
             return this.position;
     
     
         }
     
     } 

avatar image Nick4 · Jun 29, 2015 at 11:28 PM 1
Share

You shouldn't answer a question with another question, use comment section ins$$anonymous$$d :) Well I don't exactly know if it's the same case for you but it looks like you're trying to serialize Vector2 with .net's serializable which is not acceptable 'cuz type Vector2 isn't serializable itself. You can always create your own Vector2 class which would only have 2 variables (x and y) and serialize that.

avatar image Bambivalent · Mar 03, 2017 at 08:41 AM 0
Share

Thanks for the explanation. I tried to serialize a class with a vector3 attribute, and that's why it didn't work.

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

23 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

Related Questions

EndOfStreamException : Failed to read past end of stream 1 Answer

Using BinaryFormatter for deserialization - ArgumentException: method argument length mismatch 0 Answers

Saving game data: BinaryFormatter vs SoapFormatter 0 Answers

Android IL2CPP bulid crash MemoryStream deserialization 0 Answers

Serialization from WinForms to Unity 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