// ------------------------------------------------------------------------ // end: circle // cylinder // ------------------------------------------------------------------------ public static void DrawCylinder(Vector3 center, Quaternion rotation, float height, float radius, int numSegments, Color color, bool depthTest = true, Style style = Style.Wireframe) { if (height < MathUtil.Epsilon || radius < MathUtil.Epsilon) { return; } Mesh mesh = null; switch (style) { case Style.Wireframe: mesh = PrimitiveMeshFactory.CylinderWireframe(numSegments); break; case Style.SolidColor: mesh = PrimitiveMeshFactory.CylinderSolidColor(numSegments); break; case Style.FlatShaded: mesh = PrimitiveMeshFactory.CylinderFlatShaded(numSegments); break; case Style.SmoothShaded: mesh = PrimitiveMeshFactory.CylinderSmoothShaded(numSegments); break; } if (mesh == null) { return; } Material material = GetMaterial(style, depthTest, true); MaterialPropertyBlock materialProperties = GetMaterialPropertyBlock(); materialProperties.SetColor("_Color", color); materialProperties.SetVector("_Dimensions", new Vector4(radius, radius, radius, height)); materialProperties.SetFloat("_ZBias", (style == Style.Wireframe) ? s_wireframeZBias : 0.0f); Graphics.DrawMesh(mesh, center, rotation, material, 0, null, 0, materialProperties, false, false, false); }
// ------------------------------------------------------------------------ // end: box // cylinder // ------------------------------------------------------------------------ public static void DrawCylinder(Vector3 center, Quaternion rotation, float height, float radius, int numSegments, Color color, Style style = Style.SmoothShaded) { if (height < MathUtil.Epsilon || radius < MathUtil.Epsilon) { return; } Mesh mesh = null; switch (style) { case Style.Wireframe: mesh = PrimitiveMeshFactory.CylinderWireframe(numSegments); break; case Style.FlatShaded: mesh = PrimitiveMeshFactory.CylinderFlatShaded(numSegments); break; case Style.SmoothShaded: mesh = PrimitiveMeshFactory.CylinderSmoothShaded(numSegments); break; } if (mesh == null) { return; } Gizmos.color = color; if (style == Style.Wireframe) { Gizmos.DrawWireMesh(mesh, center, rotation, new Vector3(radius, height, radius)); } else { Gizmos.DrawMesh(mesh, center, rotation, new Vector3(radius, height, radius)); } }