Serialization error on loading a scene
We have a project that uses SimpleJSON to parse and save our Unity events On triggered actions.
The issue we are getting is when we call our load function between scenes. It does not load our events. Here is the error Unity is throwing out:
ArgumentException: failed to convert parameters
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:484)
System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:528)
System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:77)
UnityEngine.Events.PersistentCall.GetObjectCall (UnityEngine.Object target, System.Reflection.MethodInfo method, UnityEngine.Events.ArgumentCache arguments) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:422)
UnityEngine.Events.PersistentCall.GetRuntimeCall (UnityEngine.Events.UnityEventBase theEvent) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:389)
UnityEngine.Events.PersistentCallGroup.Initialize (UnityEngine.Events.InvokableCallList invokableList, UnityEngine.Events.UnityEventBase unityEventBase) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:562)
UnityEngine.Events.UnityEventBase.RebuildPersistentCallsIfNeeded () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:728)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:764)
UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:53)
SceneEvent.SceneEventTriggered (System.String p, TriggeredBy triggeredBy) (at Assets/Scripts/Phase/SceneEvent.cs:31)
SceneEventManager.Load (System.Collections.Generic.List`1 list) (at Assets/Scripts/Phase/SceneEventManager.cs:91)
SaveManager.Load () (at Assets/Scripts/Misc/SaveManager.cs:122)
SaveManager.Start () (at Assets/Scripts/Misc/SaveManager.cs:30)
Important to note here, we have never had this issue before we updated Unity to 5.4.0f3 After we updated Unity we got this error, which makes the game unplayable.
I've tried reverting our project to a later version and uninstalling Unity and also reverting Unity to an older version.
Please help us!
Here is the code for the load function:
public void Load() {
var itemJsonString = PlayerPrefs.GetString(itemKey);
var eventJsonString = PlayerPrefs.GetString(eventKey);
var itemJson = JSONNode.Parse(itemJsonString);
var eventJson = JSONNode.Parse(eventJsonString);
if (itemJson != null) {
inventory.loadFromItemIDs(JsonToList(itemJson));
}
if (eventJson != null) {
sceneEventManager.Load(JsonToList(eventJson));
}
}
and in our SceneEventManager:
public void Load(List<string> list)
{
for (int i = 0; i < list.Count; i++)
{
if (SceneEventTriggered != null)
{
SceneEventTriggered(list[i], TriggeredBy.CompleteLoad);
triggeredEvents = list;
print (list [i]);
}
}
}
Your answer
Follow this Question
Related Questions
Deserialize Json into Object 0 Answers
Making a POST request to Google OAuth using WWWForms 1 Answer
Unity imposed recursion depth of Json data? 0 Answers
Read and Write Textfile on mobile (C# Unity ) 0 Answers
gameObject from jso 0 Answers