UnityEditor.HandleUtility.PointOnLineParameter C# (CSharp) Méthode

PointOnLineParameter() public static méthode

Returns the parameter for the projection of the point on the given line.

public static PointOnLineParameter ( Vector3 point, Vector3 linePoint, Vector3 lineDirection ) : float
point Vector3
linePoint Vector3
lineDirection Vector3
Résultat float
        public static float PointOnLineParameter(Vector3 point, Vector3 linePoint, Vector3 lineDirection)
        {
            return (Vector3.Dot(lineDirection, point - linePoint) / lineDirection.sqrMagnitude);
        }

Usage Example

        private static float SizeHandle(Vector3 localPos, Vector3 localPullDir, Matrix4x4 matrix, bool isEdgeHandle)
        {
            Vector3 vector3_1  = matrix.MultiplyVector(localPullDir);
            Vector3 vector3_2  = matrix.MultiplyPoint(localPos);
            float   handleSize = HandleUtility.GetHandleSize(vector3_2);
            bool    changed    = GUI.changed;

            GUI.changed = false;
            Color color = Handles.color;
            float num1  = 0.0f;

            if (isEdgeHandle)
            {
                num1 = Mathf.Cos(0.7853982f);
            }
            if ((!Camera.current.orthographic ? (double)Vector3.Dot((Camera.current.transform.position - vector3_2).normalized, vector3_1) : (double)Vector3.Dot(-Camera.current.transform.forward, vector3_1)) < -(double)num1)
            {
                Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, Handles.color.a * Handles.backfaceAlphaMultiplier);
            }
            Vector3 point = Handles.Slider(vector3_2, vector3_1, handleSize * 0.03f, new Handles.DrawCapFunction(Handles.DotCap), 0.0f);
            float   num2  = 0.0f;

            if (GUI.changed)
            {
                num2 = HandleUtility.PointOnLineParameter(point, vector3_2, vector3_1);
            }
            GUI.changed  |= changed;
            Handles.color = color;
            return(num2);
        }
All Usage Examples Of UnityEditor.HandleUtility::PointOnLineParameter