slipster216 / VertexPaint

Unity 5.3 Vertex Painter
Other
906 stars 151 forks source link

Exception when deleting selected object #3

Closed apautrot closed 8 years ago

apautrot commented 8 years ago

When deleting selected object that was painted, an exception can occurs :

MissingReferenceException: The object of type 'MeshRenderer' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
JBooth.VertexPainterWindow.InitMeshes () (at Assets/Third party/VertexPaint/Editor/VertexPainterWindow_Painting.cs:95)
JBooth.VertexPainterWindow.OnSelectionChange () (at Assets/Third party/VertexPaint/Editor/VertexPainterWindow_GUI.cs:276)

A possible fix would be in VertexPainterWindow_Painting.cs, in method void InitMeshes(), to test that jobs[i].renderer isn't null :

void InitMeshes()
{
         // revert old
         for (int i = 0; i < jobs.Length; ++i)
         {
             if ( jobs[i].renderer != null )
                jobs[i].renderer.sharedMaterial = jobs[i].originalMat;
         }
         ...
slipster216 commented 8 years ago

fixed, thanks!