Potential bug upgrading from 3.59 to 3.6 RecastGenerator

Hi,

I am using recast mesh objects in one of my scenes with the collider on the game object with the RecastMeshObject script and the meshes (filters and renderers) are all on children game objects.

in 3.5.9 the Recast Generator checked safely if it only had a collider and no filter:

(567 RecastGEnerator.cs)

		for (int i=0;i<buffer2.Count;i++) {
			MeshFilter filter = buffer2[i].GetMeshFilter();
			
			if (filter != null) {
				Mesh mesh = filter.sharedMesh;
				
				ExtraMesh smesh = new ExtraMesh();
				smesh.matrix = filter.GetComponent<Renderer>().localToWorldMatrix;

However now in 3.6:

for (int i=0;i<buffer2.Count;i++) {
				MeshFilter filter = buffer2[i].GetMeshFilter();
				Renderer rend = filter.GetComponent<Renderer>();

				if (filter != null && rend != null) {
					Mesh mesh = filter.sharedMesh;

So if the game object filter is null (but with still a valid recastmeshobject) it attempts to access the renderer before the if(filter != null) check

note I did use the upgrade helper to be compliant with unity 5.0.

Thanks!

1 Like

Hi

Nicely spotted.
I have fixed it in my dev version and it will be included in the next update.