There is a code. He is not mine and he did not write it. It seems, by what I know, it is correct and there are no errors in it. But Unity3D gives an error:

(1, 15) BCE0044 unexpected char ";".

Who will help to make out a problem? I already corrected the given code a little, but all the same does not work.

#pragma strict @script ExecuteInEditMode; function Start () { } var bool : boolean = false; var ts1 : Transform[]; function Update () { if(bool){ bool : false; var ts : new Array(); for(var trans : Transform in transform){ if(!trans.active){ ts.Add(trans); } } ts1 = new Array(ts.Count); for(var i=0; i<ts.length; i++){ ts1[i] = ts[i]; } } } 
  • Remove the semicolon in the #pragma clauses, just ask. :) - Vlad from Moscow
  • @VladfromMoscow fixed the code, how it should be and get the same error prntscr.com/cyi2hh - Insider
  • But if you write that it is correct. then where are the mistakes? :) - Vlad from Moscow
  • @VladfromMoscow but honestly, I do not know ... you can double-check. I updated the code in question myself)) - Insider
  • Says that this sentence is incorrect. Bool: false; What does it mean? Maybe it means bool = false ;? The same with the following after this sentence. - Vlad from Moscow

1 answer 1

by what I know, it is correct and there are no errors in it

Blatant lie)) Syntax broken and worked? It is too magical.

Errors:

  1. bool = false; - because You have already declared the variable above, and here you need to assign a value.
  2. var ts : Array = new Array(); because you declare an array. It's strange that they didn't notice, because at the beginning of the script you already have two ads
  3. instead of if(!trans.active){ should be if(!trans.gameObject.active){ , since Transform no active property

How could this work, as you say, I can not imagine. Apparently in a parallel universe))

Total:

 #pragma strict @script ExecuteInEditMode; function Start () { } var bool : boolean = false; var ts1 : Transform[]; function Update () { if(bool){ bool = false; var ts : Array = new Array(); for(var trans : Transform in transform){ if(!trans.gameObject.active){ ts.Add(trans); } } ts1 = new Array(ts.Count); for(var i=0; i<ts.length; i++){ ts1[i] = ts[i]; } } } 
  • in a parallel universe, everything always works very well: D - Insider