Exemple #1
0
        public static void DrawXYWirePlane(float width, float height)
        {
            Vector3 a = new Vector3(-width, -height) * 0.5f;
            Vector3 b = new Vector3(width, -height) * 0.5f;
            Vector3 c = new Vector3(width, height) * 0.5f;
            Vector3 d = new Vector3(-width, height) * 0.5f;

            Gizmos.DrawLine(a, b);
            Gizmos.DrawLine(b, c);
            Gizmos.DrawLine(c, d);
            Gizmos.DrawLine(d, a);

            Color color = Gizmos.color;

            color.a = 0.4f;

            GizmosEx.PushColor(color);
            Gizmos.DrawCube(Vector3.zero, new Vector3(width, height, 0.0f));
            GizmosEx.PopColor();
        }
Exemple #2
0
        public static void DrawWireBox(Vector3 pos, Vector3 extents)
        {
            var points = new[]
            {
                // Top
                pos + new Vector3(extents.x, extents.y, extents.z) * 0.5f,
                pos + new Vector3(-extents.x, extents.y, extents.z) * 0.5f,
                pos + new Vector3(-extents.x, extents.y, -extents.z) * 0.5f,
                pos + new Vector3(extents.x, extents.y, -extents.z) * 0.5f,

                // Bottom
                pos + new Vector3(extents.x, -extents.y, extents.z) * 0.5f,
                pos + new Vector3(-extents.x, -extents.y, extents.z) * 0.5f,
                pos + new Vector3(-extents.x, -extents.y, -extents.z) * 0.5f,
                pos + new Vector3(extents.x, -extents.y, -extents.z) * 0.5f,
            };

            var directions = new[]
            {
                // Top
                new[] { Vector3.down, Vector3.left, Vector3.back },
                new[] { Vector3.down, Vector3.right, Vector3.back },
                new[] { Vector3.down, Vector3.right, Vector3.forward },
                new[] { Vector3.down, Vector3.left, Vector3.forward },

                // Bottom
                new[] { Vector3.up, Vector3.left, Vector3.back },
                new[] { Vector3.up, Vector3.right, Vector3.back },
                new[] { Vector3.up, Vector3.right, Vector3.forward },
                new[] { Vector3.up, Vector3.left, Vector3.forward },
            };

            float extent = extents.magnitude * 0.1f;

            for (int i = 0; i < 8; ++i)
            {
                GizmosEx.DrawCorner(points[i], directions[i][0], directions[i][1], directions[i][2], extent);
            }
        }