Example #1
0
    void OnDrawGizmos()
    {
        if (!Application.isPlaying)
        {
            Awake();
        }

        if (_segment == null)
        {
            return;
        }

        Gizmos.color = Color.cyan;
        Vector3 position = _transform.position;
        float   radius   = _transform.lossyScale.x * gizmosRadius;

        Gizmos.DrawSphere(position, radius);

        if (_segment.interpolationMethod == Shape2DExtrudeSegment.InterpolationMethod.Bezier)
        {
            Gizmos.color = Color.yellow;
            int controlPointIndex = Array.IndexOf(_segment.GetControlPoints(), this);
            if (controlPointIndex != 0)
            {
                Vector3 backwardHandle = _transform.position - _transform.forward * _transform.lossyScale.z;
                Gizmos.DrawLine(position, backwardHandle);
                Gizmos.DrawSphere(backwardHandle, radius / 2);
            }
            if (controlPointIndex != _segment.GetControlPoints().Length - 1)
            {
                Vector3 forwardHandle = _transform.position + _transform.forward * _transform.lossyScale.z;
                Gizmos.DrawLine(position, forwardHandle);
                Gizmos.DrawSphere(forwardHandle, radius / 2);
            }
        }
    }