Raycast all or Raycast

I want to set transparency at all objects between the camera and the player, this all works fine, but i’m missing how i would go about into restoring opacity when objects are no longer in the way.
I went about storing all objects in list and compare the hit in hits with each object but i doesnt work.

Some insight of how to tackle this problem would be apreciated.
Thanks.

Answering to myself, and for anyone that might be dealing with the same problem in the future,
It is not absent of errors and needs refactoring + fixes. If anyone willing go ahead.

private void SetTransparency()
    {
        Ray ray = new Ray(myTransform.position, (target.position - myTransform.position).normalized);
        RaycastHit[] hits = Physics.RaycastAll(ray, maxDistance);

        if (hits.Length > 0)
        {
            foreach (RaycastHit hit in hits)
            {
                if (hit.transform.gameObject != target.gameObject)
                    objectsInTheWay.Add(hit.transform.gameObject);

                objectsInTheWay = objectsInTheWay.Distinct().ToList();

                if (hit.transform.gameObject != target.gameObject)
                {
                    renderers = hit.transform.gameObject.GetComponentsInChildren(typeof(Renderer));

                    if (renderers != null)
                    {
                        SetMaterialTransparent(hit.transform.gameObject);
                        iTween.FadeTo(hit.transform.gameObject, 0.3f, 0.5f);
                    }
                }
            }
        }

        foreach (RaycastHit hit in hits)
        {
            if (hit.transform.gameObject != target.gameObject)
                newObjectsInTheWay.Add(hit.transform.gameObject);
        }
        
        foreach (GameObject obj in objectsInTheWay)
        {
            if (!newObjectsInTheWay.Contains(obj))
            {
                iTween.FadeTo(obj, 1, 1);
                Invoke("SetMaterialOpaque", 1f);
                objectsInTheWay.Remove(obj);
            }
        }

        newObjectsInTheWay.Clear();
    }