Anyway to pass by reference in a IEnumerator or something?

So I need help with a way to pass castBarCoords by reference in order to change it’s position on the canvas.Any help or ideas would be appreciate

Update(){
    ...
    if (player.casting==true) {
		MoveCastBar(castBarCoords,castStartPos,castEndPos,player.castTime);
    		}
    ...}
    
    private IEnumerator MoveCastBar(ref RectTransform castBarCoords, Vector3 start, Vector3 end,float castTime){
    		float timeLeft = Time.deltaTime;
    		float speed = 1.0f / castTime;
    		float progress = 0.0f;
    		while (progress<=1.0) {
    			castBarCoords.position = Vector3.Lerp(castStartPos, castEndPos, progress);
    			progress+=speed*Time.deltaTime;
    			timeLeft+=Time.deltaTime;
    			yield return null;
    		}
    		castBarCoords.position = castEndPos;
    	}

Answer is simple, you cannot use ref in coroutine.

But your issue does not require to pass by reference anyway. You are accessing members of RectTransform object, so it is fine.

If you were to modify castBarCoords like so

 castBarCoords = otherRectTransform;

then yes you would require some kind of ref pattern.