- Home /
Array bug or script error
Hello, Yeah array script are famous on unity answer, but this is wierd for sure, here's the begining of my script:
var Gauche:boolean[]; var Numero:int; function Start () { Numero=0; print(Gauche[Numero]); if(Gauche[Numero]==true){ //Do things } else { //Do other things } }In unity editor, Gauche[] contains allready 4 elements, and here's what i got:
![alt text](https://koobas.hobune.stream/wayback/20220612104033im_/https://answers.unity.com/storage/temp/85274-capture.png)
So, bug or script error? ^^
PS:On the screnshot, ther's written line 27, but i supprimed somes lines of the code i put on the question so that's normal ^^
So please post the actual script you're using so we can see what that line 27 error relates to...
It's the line print(Gauche[Numero]) Sorry if i haven't said that ^^
Does anywhere in your code actual declare the size or creation of Gauche[]? And if so, simply consider enclosing your code in
if (Gauche[Numero] != null)
{
}
Also, please avoid using GameObject.Find, it is a terrible method for getting the objects you are looking for. There are plenty of ways to find objects, but GameObject.Find should be a LAST RESORT.
@RobAnthem As i trier to do a Universal code, no the size isn't declaired, but the création is declared "var Gauche:boolean[];". I'll try your solution tommorow ^^
Answer by 3T3A · Jan 05, 2017 at 02:32 PM
Ok i found the solution and in fact i was stupid. The script i created is correct, but the script were also in another object that i forgot and that i haven't prepared ^^. Sorry for you alla and thanks for the response :3
Your answer
![](https://koobas.hobune.stream/wayback/20220612104033im_/https://answers.unity.com/themes/thub/images/avi.jpg)