コード例 #1
0
        private List <Vector3> GetAffectedPoints()
        {
            List <Vector3> retList = new List <Vector3>();

            retList.Add(GetStartPoint());

            CurveHandle t0 = GetStartPoint().tangentForward;
            CurveHandle t1 = GetEndPoint().tangentBackward;

            if (t0)
            {
                retList.Add((Vector3)GetStartPoint() + t0);
            }

            if (t1)
            {
                retList.Add((Vector3)GetEndPoint() + t1);
            }

            retList.Add(GetEndPoint());
            return(retList);
        }
コード例 #2
0
        /// <summary>
        /// Displays a tangent point in the Scene View.  Also controls tangent point movement.
        /// </summary>
        /// <param name="s">ControlPoint the tangent is tied to.</param>
        /// <param name="p">CurvePoint representing the tangent.</param>
        /// <param name="controlIndex">Control index of this handle.</param>
        private void ShowTangentPoint(ControlPoint s, CurveHandle p, int controlIndex)
        {
            Vector3 point = handleTransform.TransformPoint(p.point + s.point);
            float   size  = HandleUtility.GetHandleSize(point) * 0.03f;

            if (Handles.Button(point, handleRotation, size, size, Handles.DotHandleCap))
            {
                selectedIndex = controlIndex;
            }

            if (selectedIndex == controlIndex)
            {
                EditorGUI.BeginChangeCheck();
                point = Handles.DoPositionHandle(point, handleRotation);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(spline, "Move Tangent");
                    EditorUtility.SetDirty(spline);
                    p.point = handleTransform.InverseTransformPoint(point - s.point);

                    if (spline.tangentMode == TangentMode.Link)
                    {
                        if (p == s.tangentBackward && s.tangentForward != null)
                        {
                            s.tangentForward.point = -p.point;
                            Debug.Log("Aligning");
                        }
                        else if (p == s.tangentForward && s.tangentBackward != null)
                        {
                            s.tangentBackward.point = -p.point;
                            Debug.Log("Aligning");
                        }
                    }
                }
            }
        }