Skip to main content
edited body; deleted 16 characters in body
Source Link
Sean Carey
  • 694
  • 6
  • 14

I have this private coroutine in my WinDialogue script:

private IEnumerator ActivateStars(int count) { for (varint indexi = 0; indexi < count; index++i++) { _stars[index]_stars[i].SetActive(true); yield return new WaitForSeconds(.3f); } } 

And somehow I’m still able to call it from my UIManager script:

_winDialogue.GetComponent<WinDialogue>().StartCoroutine("ActivateStars", starCount); 

How can that be if I marked it as private?

I have this private coroutine in my WinDialogue script:

private IEnumerator ActivateStars(int count) { for (var index = 0; index < count; index++) { _stars[index].SetActive(true); yield return new WaitForSeconds(.3f); } } 

And somehow I’m still able to call it from my UIManager script:

_winDialogue.GetComponent<WinDialogue>().StartCoroutine("ActivateStars", starCount); 

How can that be if I marked it as private?

I have this private coroutine in my WinDialogue script:

private IEnumerator ActivateStars(int count) { for (int i = 0; i < count; i++) { _stars[i].SetActive(true); yield return new WaitForSeconds(.3f); } } 

And somehow I’m still able to call it from my UIManager script:

_winDialogue.GetComponent<WinDialogue>().StartCoroutine("ActivateStars", starCount); 

How can that be if I marked it as private?

Tweeted twitter.com/StackGameDev/status/1247539745149734913
Became Hot Network Question
Source Link
Sean Carey
  • 694
  • 6
  • 14

Why is it that I’m still able to call a coroutine from another script, even though I marked it as private?

I have this private coroutine in my WinDialogue script:

private IEnumerator ActivateStars(int count) { for (var index = 0; index < count; index++) { _stars[index].SetActive(true); yield return new WaitForSeconds(.3f); } } 

And somehow I’m still able to call it from my UIManager script:

_winDialogue.GetComponent<WinDialogue>().StartCoroutine("ActivateStars", starCount); 

How can that be if I marked it as private?