CreateCone

Author: Wolfram Kresse

Description
This editor script creates a cone with the specified tessellation (=number of vertices), top radius, bottom radius, and length. With top radius == bottom radius, the result is a cylinder. With none of the radii == 0, the result is a truncated cone. So far the resulting cone has no end caps, but you can create caps on your own by using a cone with one radius==0 and length==0.

The resulting mesh will be added as an asset to Assets/Editor, so it can be used in prefabs etc.

Note it is inevitable that a true cone (one of the radii == 0) cannot be rendered completely smooth, and will show facetting artifacts.

Usage
Place this script as "CreateCone.cs" in YourProject/Assets/Editor and a menu item will automatically appear in the "GameObject/Create Other" menu after it is compiled.

Num Vertices is the number of vertices each end will have.

Radius Top is the radius at the top. The center point will be located at (0/0/0).

Radius Bottom is the radius at the bottom. The center point will be located at (0/0/Length).

Length is the number of world units long the plane will be (+Z direction).

Opening Angle If this is >0, the top radius is set to 0, and the bottom radius is computed depending on the length, so that the given opening angle is created.

Outside defines whether the outside is visible (default).

Inside defines whether the inside is visible. Set both outside and inside to create a double-sided primitive.

Add Collider creates a matching mesh collider for the cone if checked.