Exemplo n.º 1
0
    private Vector2 SetNodeRootGizmo(int index)
    {
        Handles.color = nodeDisplayColors[index % nodeDisplayColors.Length];
        Vector2 point = spline.points[index].position;
        float   size  = handleRootSize;

        if (index == 0)
        {
            size *= 2;
        }
        if (Handles.Button(point, handleRotation, size, pickSize, Handles.DotHandleCap))
        {
            selectedUI        = SelectedCurveType.nodeRoot;
            selectedNodeIndex = index;
        }
        if (selectedUI == SelectedCurveType.nodeRoot && selectedNodeIndex == index)
        {
            EditorGUI.BeginChangeCheck();
            point = Handles.DoPositionHandle(point, handleRotation);
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(spline.points[index]);
                EditorUtility.SetDirty(spline);
                spline.points[index].position = point;
            }
        }
        return(point);
    }
Exemplo n.º 2
0
    private Vector2 SetTangentGizmo(int index, SelectedCurveType requestedUI)
    {
        Vector2 tangent = GetTangent(spline.points[index], requestedUI);

        Handles.color = nodeDisplayColors[index % nodeDisplayColors.Length];
        Vector2 point = spline.points[index].transform.TransformPoint(tangent);

        if (Handles.Button(point, handleRotation, handleTangentSize, pickSize, Handles.DotHandleCap))
        {
            selectedUI        = requestedUI;
            selectedNodeIndex = index;
        }
        if (selectedUI == requestedUI && selectedNodeIndex == index)
        {
            EditorGUI.BeginChangeCheck();
            point = Handles.DoPositionHandle(point, handleRotation);
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(spline.points[index]);
                EditorUtility.SetDirty(spline);
                tangent = spline.points[index].transform.InverseTransformPoint(point);
                SetTangent(index, requestedUI, tangent);
            }
        }

        Handles.DrawLine(point, spline.points[index].transform.position);
        return(point);
    }
Exemplo n.º 3
0
 private Vector2 GetTangent(CurveNode node, SelectedCurveType type)
 {
     if (type == SelectedCurveType.inTangent)
     {
         return(node.inTangent);
     }
     return(node.outTangent);
 }
Exemplo n.º 4
0
 private void SetTangent(int index, SelectedCurveType type, Vector2 value)
 {
     if (type == SelectedCurveType.inTangent)
     {
         spline.points[index].inTangent = value;
     }
     else
     {
         spline.points[index].outTangent = value;
     }
 }