W
W
WeBBeW2021-01-08 16:55:02
C++ / C#
WeBBeW, 2021-01-08 16:55:02

Why is nothing written to the array?

Why is nothing written to the array? Everything is output by zeros
Here is the code:

The code

void Start() {
        StartTest = StartCoroutine(TestCheck());
    }

    IEnumerator TestCheck()
    {
        while(true)
        {
            float[] StartSide  = new float[(int)Abc.transform.localScale.x];//массив координат начал сторон
            float[] EndSide = new float[(int)Abc.transform.localScale.x];//массив координат концов сторон
            if(stoped == false)
            {
                for(int i = 0; i <= (Abc.transform.localScale.x - 1);i++)
                {
                    print("Граница [" + i + "]стороны = [" + (Abc.transform.position.x - (Abc.transform.localScale.x/2 - 1 * i)) + ";" + (Abc.transform.position.x - (Abc.transform.localScale.x/2 - ((1 * i) + 1)) + "]"));
                    StartSide[i] = Abc.transform.position.x - (Abc.transform.localScale.x/2 - 1 * i);
                    EndSide[i] = Abc.transform.position.x - (Abc.transform.localScale.x/2 - ((1 * i) + 1));
                    if(i == (Abc.transform.localScale.x - 1f)) stoped = true;
                }
            }else
            {
                for(int a = 0; a <= (Abc.transform.localScale.x - 1);a++)
                {
                    print("Else - " + StartSide[a]);
                    if(a == (Abc.transform.localScale.x - 1f)) StopCoroutine(StartTest);
                }
            }
            yield return new WaitForSeconds(1f);
        }
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WeBBeW, 2021-01-08
@WeBBeW

The solution to the problem was simple. It was necessary to write arrays before while

F
freeExec, 2021-01-08
@freeExec

StartTest = StartCoroutine(TestCheck());
Curutina does not return values, to put it simply.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question