keenanwoodall / Deform

A fully-featured deformer system for Unity that lets you stack effects to animate models in real-time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error `Object reference not set to an instance of an object` on Editor stop

novavision opened this issue · comments

Describe the bug
On scene unload or editor play mode stop I get the error

NullReferenceException: Object reference not set to an instance of an object
Deform.Deformable.IsVisible () (at Library/PackageCache/com.beans.deform@3802324a6b/Code/Runtime/Mesh/Deformable.cs:235)
Deform.Deformable.ShouldCull (System.Boolean ignoreCullingMode) (at Library/PackageCache/com.beans.deform@3802324a6b/Code/Runtime/Mesh/Deformable.cs:241)
Deform.Deformable.ApplyData (System.Boolean ignoreCullingMode) (at Library/PackageCache/com.beans.deform@3802324a6b/Code/Runtime/Mesh/Deformable.cs:345)
Deform.Deformable.ApplyData () (at Library/PackageCache/com.beans.deform@3802324a6b/Code/Runtime/Mesh/Deformable.cs:359)
Deform.DeformableManager.CompleteDeformables (System.Collections.Generic.HashSet`1[T] deformables) (at Library/PackageCache/com.beans.deform@3802324a6b/Code/Runtime/Core/DeformableManager.cs:103)
Deform.DeformableManager.OnDisable () (at Library/PackageCache/com.beans.deform@3802324a6b/Code/Runtime/Core/DeformableManager.cs:77)

To Reproduce
Steps to reproduce the behavior:

  1. Add any deformer to the scene
  2. Apply deformation
  3. Hit Stop editor
  4. See error
  • OS: Windows 11, MacOS
  • Unity: 2021.2.17f1
  • Deform version: smooth-normals version 1.2.1

Thanks for the report. I was unable to reproduce the error, but since it's a simple null ref I added a null check to the line in question. Lemme know if that fixed it!

This error is about Deformable is not removed from DeformMaganager on stop (editor) or scene unload (build). Object with deformable component destroyed, but DeformManager still excute it's update.

However, this happened with me only in case if I got Deformable component disabled by default on start. I wasn't sure how is it better to toggle deformable exactly when it needed and used this approach. But, after I enabled it by defaul but jsut set update option to Stop, and toggle to Play/Pause layer on, everything worked as expected without error.