Penetration weapon needs to find all objects it passes through

I am making a weapon where the bullet can sometimes pass through certain walls and hit items on the other side, and so far I have this code:

#pragma strict

private var me : Transform;
private var rigid : Rigidbody;
private var oldPos : Vector3;

function Start () {
me=transform;
rigid=rigidbody;
oldPos=me.position;
}

function Update() {
var entry : RaycastHit;
if(Physics.Linecast(oldPos,me.position,entry)){
var exit : RaycastHit;
if(Physics.Linecast(me.position,oldPos,exit)){
var thickness=CollisionThickness(entry,exit);
print(thickness);
}
}
oldPos=me.position;
}

function CollisionThickness (entry : RaycastHit, exit : RaycastHit) {
var colthickness=Vector3.Distance(entry.point,exit.point);
return colthickness;
} 

which runs every frame on my colliderless rigidbody bullet to check whether it passed through an object that frame. It also finds how thick the object was it passed through, which I will use to calculate whether or no it should penetrate or not. But it often passes through multiple colliders in one go, and only detects the first and last entry/ exit points. This means it gives misleading thickness data, and will fail to place bulletholes on some surfaces when I have added that code in. What I want is for it to detect all entry/ exit points it goes through each frame, and get data from all of them. I tried Physics.RaycastAll but couldn’t get it to work properly.
Please could someone help with this as I have not been able to find a solution anywhere else?

I think you were on the right track using Physics.RaycastAll - the trouble likely came from the fact that RaycastAll does not necessarily return a sorted array of hits. You can sort the hits by adding your own Comparison function:

    static int CompareRaycastDistances(RaycastHit x, RaycastHit y)
    {
        if (x.distance > y.distance)
            return 1;
        if (x.distance < y.distance)
            return -1;
        return 0;
    }

… then pass this to your sort method:

        RaycastHit[] hits = Physics.RaycastAll(me.position, me.forward);
        Array.Sort(hits, CompareRaycastDistances);

… so that you have a list of hits in order from the first collider to the last. For the exits, just run the same cast in the other direction and sort.