1
I am writing a code in Unity you need to pass several values through a function, I decided to use the array in the function statement, however when I try to recover the values of the array all of them are defined as 0, the code is as follows
public class ArrayTest : MonoBehaviour{
private int[] number;
void Start(){
number = new int[] { 2, 3, 5 };
Numbers(number);
}
void Numbers(int[] numb) {
numb = new int[3];
Debug.Log("Este é o primeiro valor: " + numb[0]);
Debug.Log("Este é o segundo valor: " + numb[1]);
Debug.Log("Este é o terceiro valor: " + numb[2]);
}
}
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero