SerializationException

Dear,

After Start Awake optimisation in 151 lesson in RPG Core Combat Creator, I got this error. I can’t find how to fix it. Please help.
Thanx, Marti

SerializationException: End of Stream encountered before parsing was completed.
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run () (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Boolean isCrossAppDomain, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck, System.Runtime.Remoting.Messaging.IMethodCallMessage methodCallMessage) (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Boolean fCheck) (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
RPG.Saving.SavingSystem.LoadFile (System.String saveFile) (at Assets/Scripts/Saving/SavingSystem.cs:53)
RPG.Saving.SavingSystem+d__0.MoveNext () (at Assets/Scripts/Saving/SavingSystem.cs:16)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <88d854ea2c91426ebc464f01cd71aa85>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
RPG.SceneManagement.SavingWrapper:Awake() (at Assets/Scripts/SceneManagement/SavingWrapper.cs:16)
UnityEngine.Object:Instantiate(GameObject)
RPG.Core.PresistentObjectsSpawner:SpawnPresistentObject() (at Assets/Scripts/Core/PresistentObjectsSpawner.cs:24)
RPG.Core.PresistentObjectsSpawner:Awake() (at Assets/Scripts/Core/PresistentObjectsSpawner.cs:17)

This exception happens (in the RPG course) because you added/changed some stuff that are saved by the saving system, but you still have an old save. Should be resolved if you delete the save file

I have deleted Save file. When I save, then I have error with LazyValue and after I stop and played again the first error is back.

Thanks for answer,
Marti


Ah, ok. It appears that somewhere you are trying to ‘save’ the LazyValue. You cannot do that because it is not serializable. You need to save LazyValue<...>.value. Check everywhere that you are using LazyValue and in CaptureState() you need to change it to not save the whole variable, but just the <variable>.value. Also make sure that when you RestoreState(...) you are setting the <variable>.value and not the whole variable

3 Likes

Dear bixarrio,

That works.
Thanx a lot. You are the king.

Have a nice day,
Marti

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms