Can I use a raycast to retrieve information from the collider?

I’m in need of this setup:

alt text

Is this possible? I’ve been playing around with variables, and it seems like it should work.

You can easily get information about an object that has been hit with RaycastHit.

Example:

var ray : Ray;
var hit : RaycastHit;
var objectBounds : Bounds;

function Update() {
	ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	
	if (Physics.Raycast(ray, hit)) {
		objectBounds = hit.transform.renderer.bounds;
		Debug.Log(objectBounds);
	}
}

You can easily switch the variable type to store different information, as well as using the RaycastHit information directly.

If the Oject’s Value(length,height or something else) contained in the object’s script(name ObjectValue.cs add to the object,I use c#,you can try in js)
you can use

rayCasthit.collider.transform.GetComponent<ObjectValue>().length;

to get the length,
but if you want the object’s information without script,You may set the scale I think.