Ejemplo n.º 1
0
    // Draw ControlPoints
    private void ShowControlPointButton(int spline, int index, int handle, Vector3 position, bool selected)
    {
        float size = HandleUtility.GetHandleSize(position);

        Handles.color = selected ? Color.white : Color.blue;

        if (Handles.Button(position, componentRotation, size * handleSize, size * pickSize, Handles.DotHandleCap))
        {
            selectedIndex  = index;
            selectedHandle = handle;
            activeSpline   = spline;
            handleRotation = Quaternion.identity;
            pointRotation  = component.GetRotation(spline, index);
            Repaint();
        }
        if (selected)
        {
            switch (Tools.current)
            {
            case Tool.Move:
                if (selectedHandle == handle)
                {
                    MoveHandle(index, handle, position);
                }
                break;

            case Tool.Rotate:
                if (handle == 0)
                {
                    RotationHandle(index, position);
                }
                break;

            case Tool.Scale:
                if (handle == 0)
                {
                    ScaleHandle(index, position);
                }
                break;
            }
        }
    }
Ejemplo n.º 2
0
    // Draw splines and handles
    private void OnSceneGUI()
    {
        component          = target as SplineComponent;
        componentTransform = component.transform;
        componentRotation  = Tools.pivotRotation == PivotRotation.Local ? componentTransform.rotation : Quaternion.identity;

        DrawBeziers();

        if (Tools.pivotRotation != currentPivotRotation)
        {
            currentPivotRotation = Tools.pivotRotation;
            handleRotation       = Quaternion.identity;
            if (activeSpline >= 0 && selectedIndex >= 0)
            {
                pointRotation = component.GetRotation(activeSpline, selectedIndex);
            }
        }
    }