ArrayTypeMismatchException on install

I imported the package, then I:

  1. Created an empty GameObject
  2. Dragged the Astarpath.cs script to it
  3. Added a Grid Graph

Upon clicking play at this point, I get:

ArrayTypeMismatchException: Source array type cannot be assigned to destination array type.
Pathfinding.Serialization.AstarSerializer.DeserializeEditorSettings (Pathfinding.GraphEditorBase[] graphEditors) (at Assets/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs:728)
AstarPathEditor+c__AnonStorey2.<>m__2 (Boolean force) (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:2282)
AstarPath.ProcessWorkItems (Boolean force) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:800)

Deleting the Grid Graph clears the error. Anyone know what may be causing this problem?

Um… no Idea at all…
I mean… the DeserializeEditorSettings method doesn’t even assign arrays…

Could you post the exact line that is throwing the error?

Also, are you possibly using another version of Json.Net in your project?

I’ve never specifically downloaded another version of Json.Net, but I guess it’s possible that something else installed one.

I’m guessing it has something to do with my project being in JS. It doesn’t stop the Unity compiler from running my code, but MonoDevelop always complains (about that and many other things, grr).

hm… Well, I really have no idea. I have never seen that before.

No worries. If I get around to fixing it, I will let you know, but it doesn’t seem to be inhibiting my development.

I’m seeing this exact error on play

ArrayTypeMismatchException: Source array type cannot be assigned to destination array type.
Pathfinding.Serialization.AstarSerializer.DeserializeEditorSettings (Pathfinding.GraphEditorBase[] graphEditors) (at assets/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs:728)
AstarPathEditor+c__AnonStorey2.<>m__2 (Boolean force) (at assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:2282)
AstarPath.ProcessWorkItems (Boolean force) (at assets/AstarPathfindingProject/Core/AstarPath.cs:800)

Seems to go away if I lower an A Star AI’s next waypoint distance past a certain threshold (1.2 in this case)

I also immediately get this issue. Happened upon upgrading. Started fresh, and still get the error.

ArrayTypeMismatchException: Source array type cannot be assigned to destination array type.
Pathfinding.Serialization.AstarSerializer.DeserializeEditorSettings (Pathfinding.GraphEditorBase[] graphEditors) (at Assets/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs:787)
AstarPathEditor+c__AnonStoreyA.<>m__12 (Boolean force) (at Assets/Editor/Astar/AstarPathEditor.cs:2391)
AstarPath.ProcessWorkItems (Boolean force) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:812)

This happens every time the editor starts or stops playing

I have actually also gotten this error once now. Unfortunately only once, so it is hard to know what the problem is since I cannot replicate it. I think there are some lines in the json library which is causing it.

I also got this error when updating a project with the new version of your free pathfinding engine. Would posting the project help?

Hey there… I found a condition that might help you debug this error… It only seems to happen when the GameObject that has the grids is selected - so it might be something in the OnDrawGizmosSelected() or similar function… also would explain why it doesnt seem to actually cause any actual failure in the pathfinding…

I get this error every time I select the object with Astar Path attached and it renders the grid graph:
ArrayTypeMismatchException: Source array type cannot be assigned to destination array type.
Pathfinding.Serialization.AstarSerializer.DeserializeEditorSettings (Pathfinding.GraphEditorBase[] graphEditors) (at Assets/Plugins/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs:728)
AstarPathEditor+c__AnonStorey2.<>m__2 (Boolean force) (at Assets/AstarPathfindingEditor/Editor/AstarPathEditor.cs:2282)
AstarPath.ProcessWorkItems (Boolean force) (at Assets/Plugins/AstarPathfindingProject/Core/AstarPath.cs:800)

which points me to this line if I double click it:
reader.PopulateObject (ref graphEditors[i]);

But as previously mentioned it doesn’t seem to affect anything, the AI works fine. If it makes any difference I’m in a 2D project so my grid is on the XY plane.

when i start and stop running my project i get

ArrayTypeMismatchException: Source array type cannot be assigned to destination array type.
Pathfinding.Serialization.AstarSerializer.DeserializeEditorSettings (Pathfinding.GraphEditorBase[] graphEditors) (at Assets/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs:787)
AstarPathEditor+c__AnonStorey2.<>m__3 (Boolean force) (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:2391)
AstarPath.ProcessWorkItems (Boolean force) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:812)

i clear cache does not help eventually it starts up again

any idea what is causing it and how it can be resolved…

f u put Debug.Log (entryText); Assets/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs:785 just above where it fails and run it it gives you the following string

{“locked”:true,“showExtra”:false,“textureVisible”:true,“pivot”:“Center”}
UnityEngine.Debug:Log(Object)
Pathfinding.Serialization.AstarSerializer:DeserializeEditorSettings(GraphEditorBase[]) (at Assets/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs:785)
c__AnonStorey2:<>m__3(Boolean) (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:2391)
AstarPath:ProcessWorkItems(Boolean) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:812)
AstarPath:PerformBlockingActions(Boolean, Boolean) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:718)
AstarPath:FlushWorkItems() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:952)
AstarPath:AddWorkItem(AstarWorkItem) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:775)
AstarPathEditor:DeserializeGraphs(Byte[]) (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:2384)
AstarPathEditor:DeserializeGraphs() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:2379)
AstarPathEditor:LoadGraphs() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:2327)
AstarPathEditor:OnEnable() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:226)

just before the exception

so why would it not be able reader.PopulateObject (ref graphEditors[i]); the following string

{“locked”:true,“showExtra”:false,“textureVisible”:true,“pivot”:“Center”}

also why does the stack trace not show us what happends inside reader.PopulateObject?

I guess we dont get source to Pathfinding.JsonFx? or it is some .NET .dll? That sort of sucks since inside is where the problem is happening…

Could you release the source code to all the plugins, I mean I have pro version it sort of silly for something like this…

Hi

I am still not quite sure why this happens. But here are the source for that library if you want to check it out: https://bitbucket.org/TowerOfBricks/jsonfx-for-unity3d

All other dependencies which are bundled as .dlls are also open source, you can find the URLs to their repositories by looking in the dependencies.txt file in AstarPathfindingProject/Plugins.

In JsonSerializer.cs line 787 it have “reader.PopulateObject (ref graphEditors[i]);”

If I changed this to
GraphEditorBase graphEditor = graphEditors[i];
reader.PopulateObject (ref graphEditor);
graphEditors[i] = graphEditor;

fixed it.

@sanpats that fixed it for me as well.

Hi

Ok, I have no idea why that fix works… but as it seems to work, I have updated the project (3.4.0.6) to include that fix.

Seems like there’s a bug in mono/unity+mono when co-variance is mixed with arrays.
(Source : http://answers.unity3d.com/questions/456135/c-covariancearrays-raises-arraytypemismatchexcepti.html)