How do I call a method with variables in it?

Hello all,

Can’t get it right.
Please take a look at this code:

  private IEnumerator FillBar()
    {
        timer = 0f;
        while(timer<fillTime)
        {
            timer += Time.deltaTime;
            myImage.fillAmount = timer / fillTime;
    ...... [things happening here]....

        }

        ChangeSphere ();  //CANT GET THIS RIGHT! 

    }
    public void ChangeSphere(Transform nextSphere)
    {

        //Start the fading process
        StartCoroutine(FadeCamera(nextSphere));

    }

After the coroutine is finished I want to call “public void ChangeSphere” but I don’t know how to pass this call. I tried: ChangeSphere (nextSphere)
but I get “nextSphere is not familiar”

Please tell me how do I call such functions with variables.

This is a first grader’s question that cant seem to sink in.

THANKS!

@Eco-Editor

You need a reference to a variable that exists in that function. If the scipt is attached to a gameObject you can use ChangeSphere (transform); otherwise you can make a reference like so:

//From the editor just drag in your object 
public Transform transformToUse;

//Then call your function:

ChangeSphere(transformToUse);

//Or you could do this

Transform transformToUse;

void Start() {
    transformToUse = transform;
}

//Then call your function using the new reference:
ChangeSphere(transformToUse);