How to check mesh type

Hello! I am still practicing with Unity and doing tiny things just to learn.

I was trying to do a random transform for a prefab. It is ok for position and scale, but I have a little problem with rotation.

Some assets (or prefabs) have a plane in their mesh. I was trying to make that if they have a plane in it’s mesh do not touch the X and Z axis so the player will still can see it from his point of view.

I managed to do it with the next:

if (item.GetComponent<MeshFilter>().sharedMesh.ToString () == "Plane (UnityEngine.Mesh)")
            Debug.Log ("I am a Plane");
        else
            Debug.Log ("I am not a plane!");

It works, but I am not sure if it is the better way to do it. I mean… Could a mesh be a plane but not be part of UnityEngine.Mesh?

Thanks so much for your help!

A better way might be to find the bounding box for the item. If the bounding box height (Y extent) is less than some small value, then whether it’s a plane or not, you know it’s very thin, so you want to treat it as such.

Thanks for the reply! Yeah, it look better and then the user will not care about if it is a plane or not at all. And if isn’t a plane really but it is thin it will do the same effect.

I must investigate about bounds :stuck_out_tongue: