• Unity
  • Error with new submeshes?

NullReferenceException: Object reference not set to an instance of an object
Spine.Unity.SkeletonRenderer.LateUpdate () (at Assets/External/spine-unity/Assets/spine-unity/SkeletonRenderer.cs:699)

// CheckIfMustUpdateMaterialArray (last pushed materials vs currently parsed materials)
// Needs to check against the Working Submesh Instructions Materials instead of the cached submeshMaterials.
{
   var lastPushedMaterials = this.sharedMaterials;
   bool mustUpdateRendererMaterials = mustUpdateMeshStructure ||
      (lastPushedMaterials.Length != workingSubmeshInstructions.Count);

   if (!mustUpdateRendererMaterials) {
      var workingSubmeshInstructionsItems = workingSubmeshInstructions.Items;
      for (int i = 0, n = lastPushedMaterials.Length; i < n; i++) {
         if (lastPushedMaterials[i].GetInstanceID() != workingSubmeshInstructionsItems[i].material.GetInstanceID()) {   // Bounds check is implied above.
            mustUpdateRendererMaterials = true;
            break;
         }
      }
   }

workingSubmeshInstructionsItems.material is null.

I have this too
if your animation at first frame don't assign any image to slot
runtime will think the animation don't need material
so the materials in MeshRenderer at this time is empty
this will happen randomly when switch animation
hope this can be fix
or our animators need to check every animation at first frame have image or not

by the way
I found a ghost bug happen when you back to editormode from play
the ghost script will throw some null reference

Thanks for also reporting with repro steps @zeuxgame.

Can you post a new topic and an error log for that other bug?

I think I've found the problem for your case. Possibly also fixes Xelnath's case. Will post the fix in a bit.

EDIT:
To apply this fix immediately, please open your SkeletonRenderer.cs file and replace its contents with this: https://raw.githubusercontent.com/EsotericSoftware/spine-runtimes/master/spine-unity/Assets/spine-unity/SkeletonRenderer.cs

This change will be included in the next .unitypackage update.