Can enumerators modify public script variables?

I am using an enumarotor because I have to wait for user input before I can continue with the code. I modify a variable in the enumerator, and a Debug.Log shows that it has been changed, but when I check the variable that was fed as an Argument, it has not been changed. By the way, the variable I want to change is a string in a struct.

Can you maybe post a code example?
An Enumerator is still “just” a function and does not scope differently than any other.

private int _myNumber = 0;

void Start() {

IEnumerator IncrementNumber(int num) {
    int localNumber = num;
    while (true) {
        yield return new WaitForSeconds(1);
        localNumber++; // Will not change the passed _myNumber at all
        _myNumber++; // Changes the declared _myNumber directly

Hello @Boyaxchyan

An Ienumerator function, is just a method like any other. It changes the variables the same way as any other method like a void method. If you dont get what you pretend, is for something else, you need to find what, but the problem is not for beein in a Ienumerator.

Bye! :smiley: