Beispiel #1
0
        public void DrawGizmosAndClear()
        {
            var collisionCount = collisions.Count;

            for (int collisionIndex = 0; collisionIndex < collisionCount; collisionIndex++)
            {
                var collision = collisions[collisionIndex];
                Handles.color = (collision.collisionStatus == SpringBone.CollisionStatus.HeadIsEmbedded) ?
                                Color.red : Color.yellow;
                Handles.DrawWireDisc(collision.position, collision.normal, collision.radius);
                HandlesUtil.DrawArrow(
                    collision.position, collision.position + collision.normal * 0.1f, Handles.color, 0.1f);
            }
            ClearCollisions();
        }
        public void DrawGizmos(Color color)
        {
            const int PointCount = 4;

            if (localGizmoPoints == null ||
                worldGizmoPoints == null ||
                localGizmoPoints.Length < PointCount ||
                worldGizmoPoints.Length < PointCount)
            {
                localGizmoPoints = new Vector3[PointCount];
                worldGizmoPoints = new Vector3[PointCount];
            }

            var halfWidth  = 0.5f * width;
            var halfHeight = 0.5f * height;

            localGizmoPoints[0] = new Vector3(-halfWidth, -halfHeight, 0f);
            localGizmoPoints[1] = new Vector3(halfWidth, -halfHeight, 0f);
            localGizmoPoints[2] = new Vector3(halfWidth, halfHeight, 0f);
            localGizmoPoints[3] = new Vector3(-halfWidth, halfHeight, 0f);

            for (int pointIndex = 0; pointIndex < PointCount; pointIndex++)
            {
                worldGizmoPoints[pointIndex] = transform.TransformPoint(localGizmoPoints[pointIndex]);
            }

            UnityEditor.Handles.color = color;
            for (int pointIndex = 0; pointIndex < PointCount; pointIndex++)
            {
                var endPointIndex = (pointIndex + 1) % PointCount;
                UnityEditor.Handles.DrawLine(worldGizmoPoints[pointIndex], worldGizmoPoints[endPointIndex]);
                UnityEditor.Handles.DrawLine(worldGizmoPoints[pointIndex], worldGizmoPoints[pointIndex] - 0.15f * transform.forward);
            }

            HandlesUtil.DrawArrow(transform.position, transform.position + transform.forward * 0.1f, color, 0.1f);

            if (colliderDebug != null)
            {
                colliderDebug.DrawGizmosAndClear();
            }
        }