コード例 #1
0
        // 绘制 Spline 控件
        void DrawSplineControls()
        {
            _location.time = 0.5f;
            _count         = segmentCount;

            for (_location.index = 0; _location.index < _count; _location.index++)
            {
                EditorKit.BeginHotControlChangeCheck();

                if (_selectedItem == _location.index)
                {
                    Handles.color = _capSelectedColor;
                }
                else
                {
                    Handles.color = _capNormalColor;
                }

                _handleSize = HandleUtility.GetHandleSize(_middle = GetPoint(_location)) * _splineCapSize;
                Handles.FreeMoveHandle(_middle, _identityQuaternion, _handleSize, _zeroVector3, Handles.CircleCap);

                if (EditorKit.EndHotControlChangeCheck() == HotControlEvent.MouseDown)
                {
                    _selectionType = SelectionType.Spline;
                    _selectedItem  = _location.index;
                }
            }
        }
コード例 #2
0
        // 绘制 Node 控件
        void DrawNodeControls(bool edit)
        {
            _count = nodeCount;

            for (int i = 0; i < _count; i++)
            {
                // 获取 Node 位置
                _node = GetNodePosition(i);

                // 绘制 Node

                EditorGUI.BeginChangeCheck();
                EditorKit.BeginHotControlChangeCheck();

                if (_selectionType == SelectionType.Node && _selectedItem == i)
                {
                    Handles.color = _capSelectedColor;
                }
                else
                {
                    Handles.color = _capNormalColor;
                }

                _handleSize = HandleUtility.GetHandleSize(_node) * _controlPointCapSize;
                _node       = Handles.FreeMoveHandle(_node, _identityQuaternion, _handleSize, _zeroVector3, Handles.DotCap);

                // 更新选择
                if (EditorKit.EndHotControlChangeCheck() == HotControlEvent.MouseDown)
                {
                    _selectionType = SelectionType.Node;
                    _selectedItem  = i;
                }

                // 修改 Node
                if (EditorGUI.EndChangeCheck() && edit)
                {
                    Undo.RecordObject(this, undoNode);
                    SetNodePosition(i, _node);
                    EditorUtility.SetDirty(this);
                }
            }
        }
コード例 #3
0
        // 绘制 Node 控件
        void DrawNodeControls(bool edit)
        {
            _count = nodeCount;

            for (int i = 0; i < _count; i++)
            {
                // 获取控制点位置
                _back    = GetBackControlPoint(i);
                _forward = GetForwardControlPoint(i);
                _middle  = GetMiddleControlPoint(i);

                // 绘制切线
                Handles.color = _controlLineColor;
                EditorKit.HandlesDrawAALine(_back, _middle);
                EditorKit.HandlesDrawAALine(_forward, _middle);

                // 绘制后控制点

                EditorGUI.BeginChangeCheck();
                EditorKit.BeginHotControlChangeCheck();

                if (_selectionType == SelectionType.BackControlPoint && _selectedItem == i)
                {
                    Handles.color = _capSelectedColor;
                }
                else
                {
                    Handles.color = _capNormalColor;
                }

                _handleSize = HandleUtility.GetHandleSize(_back) * _controlPointCapSize;
                _back       = Handles.FreeMoveHandle(_back, _identityQuaternion, _handleSize, _zeroVector3, Handles.DotCap);

                // 更新选择
                if (EditorKit.EndHotControlChangeCheck() == HotControlEvent.MouseDown)
                {
                    _selectionType = SelectionType.BackControlPoint;
                    _selectedItem  = i;
                }

                // 修改后控制点
                if (EditorGUI.EndChangeCheck() && edit)
                {
                    Undo.RecordObject(this, undoBackControlPoint);
                    SetBackControlPoint(i, _back);
                    EditorUtility.SetDirty(this);
                }

                // 绘制中控制点

                EditorGUI.BeginChangeCheck();
                EditorKit.BeginHotControlChangeCheck();

                if (_selectionType == SelectionType.MiddleControlPoint && _selectedItem == i)
                {
                    Handles.color = _capSelectedColor;
                }
                else
                {
                    Handles.color = _capNormalColor;
                }

                _handleSize = HandleUtility.GetHandleSize(_middle) * _controlPointCapSize;
                _middle     = Handles.FreeMoveHandle(_middle, _identityQuaternion, _handleSize, _zeroVector3, Handles.DotCap);

                // 更新选择
                if (EditorKit.EndHotControlChangeCheck() == HotControlEvent.MouseDown)
                {
                    _selectionType = SelectionType.MiddleControlPoint;
                    _selectedItem  = i;
                }

                // 修改中控制点
                if (EditorGUI.EndChangeCheck() && edit)
                {
                    Undo.RecordObject(this, undoMiddleControlPoint);
                    SetMiddleControlPoint(i, _middle);
                    EditorUtility.SetDirty(this);
                }

                // 绘制前控制点

                EditorGUI.BeginChangeCheck();
                EditorKit.BeginHotControlChangeCheck();

                if (_selectionType == SelectionType.ForwardControlPoint && _selectedItem == i)
                {
                    Handles.color = _capSelectedColor;
                }
                else
                {
                    Handles.color = _capNormalColor;
                }

                _handleSize = HandleUtility.GetHandleSize(_forward) * _controlPointCapSize;
                _forward    = Handles.FreeMoveHandle(_forward, _identityQuaternion, _handleSize, _zeroVector3, Handles.DotCap);

                // 更新选择
                if (EditorKit.EndHotControlChangeCheck() == HotControlEvent.MouseDown)
                {
                    _selectionType = SelectionType.ForwardControlPoint;
                    _selectedItem  = i;
                }

                // 修改前控制点
                if (EditorGUI.EndChangeCheck() && edit)
                {
                    Undo.RecordObject(this, undoForwardControlPoint);
                    SetForwardControlPoint(i, _forward);
                    EditorUtility.SetDirty(this);
                }
            }
        }