Example #1
0
        // ------------------------------------------------------------------------
        // end: rect


        // circle
        // ------------------------------------------------------------------------

        // draw a circle on the XZ plane centered at origin in object space
        public static void DrawCircle(Vector3 center, Quaternion rotation, float radius, int numSegments, Color color, bool depthTest = true, Style style = Style.Wireframe)
        {
            if (radius < MathUtil.Epsilon)
            {
                return;
            }

            Mesh mesh = null;

            switch (style)
            {
            case Style.Wireframe:
                mesh = PrimitiveMeshFactory.CircleWireframe(numSegments);
                break;

            case Style.SolidColor:
                mesh = PrimitiveMeshFactory.CircleSolidColor(numSegments);
                break;

            case Style.FlatShaded:
            case Style.SmoothShaded:
                mesh = PrimitiveMeshFactory.CircleFlatShaded(numSegments);
                break;
            }
            if (mesh == null)
            {
                return;
            }

            Material material = GetMaterial(style, depthTest, false);
            MaterialPropertyBlock materialProperties = GetMaterialPropertyBlock();

            materialProperties.SetColor("_Color", color);
            materialProperties.SetVector("_Dimensions", new Vector4(radius, radius, radius, 0.0f));
            materialProperties.SetFloat("_ZBias", (style == Style.Wireframe) ? s_wireframeZBias : 0.0f);

            Graphics.DrawMesh(mesh, center, rotation, material, 0, null, 0, materialProperties, false, false, false);
        }