// ------------------------------------------------------------------------ // end: sphere // capsule // ------------------------------------------------------------------------ public static void DrawCapsule(Vector3 center, Quaternion rotation, float height, float radius, int latSegmentsPerCap, int longSegmentsPerCap, 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.CapsuleWireframe(latSegmentsPerCap, longSegmentsPerCap, true, true, false); break; case Style.SolidColor: mesh = PrimitiveMeshFactory.CapsuleSolidColor(latSegmentsPerCap, longSegmentsPerCap, true, true, false); break; case Style.FlatShaded: mesh = PrimitiveMeshFactory.CapsuleFlatShaded(latSegmentsPerCap, longSegmentsPerCap, true, true, false); break; case Style.SmoothShaded: mesh = PrimitiveMeshFactory.CapsuleSmoothShaded(latSegmentsPerCap, longSegmentsPerCap, true, true, false); 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); }