// ------------------------------------------------------------------------ // end: line // box // ------------------------------------------------------------------------ public static void DrawBox(Vector3 center, Quaternion rotation, Vector3 dimensions, Color color, Style style = Style.FlatShaded) { if (dimensions.x < MathUtil.Epsilon || dimensions.y < MathUtil.Epsilon || dimensions.z < MathUtil.Epsilon) { return; } Mesh mesh = null; switch (style) { case Style.Wireframe: mesh = PrimitiveMeshFactory.BoxWireframe(); break; case Style.FlatShaded: case Style.SmoothShaded: mesh = PrimitiveMeshFactory.BoxFlatShaded(); break; } if (mesh == null) { return; } Gizmos.color = color; if (style == Style.Wireframe) { Gizmos.DrawWireMesh(mesh, center, rotation, dimensions); } else { Gizmos.DrawMesh(mesh, center, rotation, dimensions); } }
// ------------------------------------------------------------------------ // end: line // box // ------------------------------------------------------------------------ public static void DrawBox(Vector3 center, Quaternion rotation, Vector3 dimensions, Color color, bool depthTest = true, Style style = Style.Wireframe) { if (dimensions.x < MathUtil.Epsilon || dimensions.y < MathUtil.Epsilon || dimensions.z < MathUtil.Epsilon) { return; } Mesh mesh = null; switch (style) { case Style.Wireframe: mesh = PrimitiveMeshFactory.BoxWireframe(); break; case Style.SolidColor: mesh = PrimitiveMeshFactory.BoxSolidColor(); break; case Style.FlatShaded: case Style.SmoothShaded: mesh = PrimitiveMeshFactory.BoxFlatShaded(); break; } if (mesh == null) { return; } Material material = GetMaterial(style, depthTest, false); MaterialPropertyBlock materialProperties = GetMaterialPropertyBlock(); materialProperties.SetColor("_Color", color); materialProperties.SetVector("_Dimensions", new Vector4(dimensions.x, dimensions.y, dimensions.z, 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); }