Unity 5.1.2 Editor problem: IndexOutOfRangeException with NetworkBehaviour

Hallo,

I upgraded to Unity 5.1.2f1 Personal and since then my project is not working anymore.
There is a Prefab called “Entity” that is throwing error messages in the concole.

IndexOutOfRangeException: Array index is out of range.
UnityEditor.NetworkBehaviourInspector.OnInspectorGUI () (at C:/buildslave/unity/build/Extensions/Networking/Editor/NetworkBehaviourInspector.cs:122)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1162)
UnityEditor.DockArea:OnGUI()

This error is thrown at start of Unity Editor and everytime when I scroll the inspector for Entity.
In 5.1.1 it worked fine.

At start there is lonely error message, that is thrown when I select the Entity prefab in Editor:
NullReferenceException: Object reference not set to an instance of an object
EntityScript…ctor ()
UnityEditor.DockArea:OnGUI()

IndexOutOfRangeException is written to console multipletimes. So when scrolling the inspector I end up with lots of IndexOutOfRangeException entries.

GameObject Entity has following components:
-Transform
-NetworkIdentity
-EntityScript (which is a NetworkBehaviour)

In order to fix this, I tried followign things:
-Removed all SyncVars from EntityScript
-Removed NetworkTeransform component
-Set the HideInEditor tag to several public variables in EntityScript
-Changed the base class of EntityScript from EntityBaseClass (baseclass network behaviour) to NetworkBehaviour
-Removed all components except the Transform from Entity and put them back in again

I am running out of ideas and any help is welcome.

Thanks

I finally found the culprit.

There seems to be a bug with SyncLists. When your SyncList ist public, you have to put it at the very beginning of your source file before any other variable declaration.

Or you can make it private or protected.

1 Like