The problem here is that DrawRay doesn’t allow a distance parameter, how can I draw the distance declared in Raycast using Drawray?

I’ve observed that if I multiply the parameter direction of Drawray, a bigger line is drawn, If I let just the direction without multipliers, is the same as my “1” distance in Raycast?

Fisrt we need to know what the DrawRay function expects from parameters

It wants the origin point, the direction and the distance of the ray (you can also give it a color, and other parameters).

public static void DrawRay(Vector3 start, Vector3 dir, Color color = Color.white, float duration = 0.0f, bool depthTest = true);

So now we need to know the direction between our ray origin and our ray.point position, to find we can use a substraction…

If one point in space is subtracted from another, then the result is a
vector that “points” from one object to the other:

// Gets a vector that points from the player's position to the target's.
var heading = hit.point - ray.origin;

Now with this info we can get the direction and the distance of our ray

var distance = heading.magnitude;
var direction = heading / distance; // This is now the normalized direction.

And this will be the resulting code…

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
// Gets a vector that points from the player's position to the target's.
var heading = hit.point - ray.origin;
var distance = heading.magnitude;
var direction = heading / distance; // This is now the normalized direction.
Debug.DrawRay(ray.origin, direction * distance, Color.red);
}