Beispiel #1
0
        void DoDrawGizmos()
        {
            _pathMatrix.SetTRS(transform.position, transform.rotation, new Vector3(_worldScale, _worldScale, _worldScale));
            EditorKit.RecordAndSetHandlesMatrix(ref _pathMatrix);

            // 绘制路径

            int highlight = _currentEditing == this ? highlightSplineIndex : -1;

            for (int i = 0; i < _localSegments.Count; i++)
            {
                _localSegments[i].Draw(highlight == i ? _highlightColor : _normalColor, _splineWidth);
            }

            // 绘制箭头

            EditorKit.RecordAndSetHandlesColor(_highlightColor);

            Vector3 point    = _localSegments[_localSegments.Count - 1].GetPoint(1f);
            float   scale    = HandleUtility.GetHandleSize(point) / Mathf.Abs(_worldScale);
            Vector3 vector   = new Vector3(0.08f, 0f, -0.24f) * scale;
            var     rotation = Quaternion.LookRotation(_localSegments[_localSegments.Count - 1].GetTangent(1f), Vector3.up);

            Handles.DrawLine(point, point + rotation * vector);
            vector.x = -vector.x;
            Handles.DrawLine(point, point + rotation * vector);

            EditorKit.RestoreHandlesColor();

            EditorKit.RestoreHandlesMatrix();
        }