This line in my code is causing the mesh assigned to “target” to be replaced by an instance, but all I want is to read the information from its bounds property. How can I keep my MeshFilter untouched?
myBounds = target.GetComponent( MeshFilter ).mesh.bounds;
Ok, well the clumsy answer appears to be this:
var dummy = Instantiate(target);
myBounds = dummy.GetComponent( MeshFilter ).mesh.bounds;
Destroy(dummy.gameObject);
It feels wasteful to duplicate the whole GO and all its components. Is there a way for me to somehow copy just the bounds object (i.e. not reference it)?
Try using sharedMesh instead of mesh when you read its bounds.
Interesting. I’m beginning to understand. Thank you!