Z
Z
Zefirot2022-03-28 15:54:41
Unity
Zefirot, 2022-03-28 15:54:41

Where is the array being lost?

Here I fill an array and fill it with prefabs

public Achievement[] ArrayAchievements;

private void Start(){
  Achievement[] ArrayAchievements = new Achievement[10];
  for(int i = 0; i < ArrayAchievements.Length; ++i){
    ArrayAchievements[i] = Instantiate(achievement) as Achievement;
    }
  Debug.Log(ArrayAchievements.Length);
  }

public void PressButtonTest(int c){
  Debug.Log(ArrayAchievements.Length);
  }

I debug displays the number of elements, I also see that the prefabs on the stage, when you click on the button (PressButtonTest) the number is 0, and in the editor I see that the array is empty, how so? Where is he lost?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question