Hi everyone
I need your expertise on some recurrent issue.
[...] // beginning of the function which create a GUI window
// planetServices is an array well defined :
// planetServices[0] = 0
// planetServices[1] = 1
// planetServices[2] = 2
// planetServices[3] = 3
for( var i=0 ; i<planetServices.length ; i++ )
{
print( "handleGUI planetServices["+i+"]="+planetServices[i] ); // that line show for example "handleGUI planetServices[0]=0"
GUILayout.Label( formatGameConfig( "services", planetServices[i] ) );
}
[...]
} // end of that function
function formatGameConfig( catName: String, id: int )
{
var configArray = assocArrayGet( game, catName ); // get a value in a pseudo associativ array
// config Array is an array well defined too
// in that case, with catName = "services"
// configArray[0]="repair"
// configArray[1]="moduleretailer"
// configArray[2]="training"
// configArray[4]="recruitment"
// the values of planetServices are the keys of configArray
print( "formatgameconfig id="+id); // that line show "formatgameconfig id=48" !
print( "formatgameconfig config["+id+"]="+configArray[id] ); // the error is throw on that line. The problem is configArray[id]
return configArray[id]
}
The windows created with the first function should display 4 labels :
repair
moduleretailer
training
recruitment
But instead, Unity kept throwing me the same error (ArgumentOutOfRangeException).
My debug lines shows that for some reason, the variable id in the second function is always equal to 48 but planetServices is never equal to 48.
When I replace planetServices by an int, 3 for example, the 4 labels show “recruitment” correctly.
During my workaround, the value of id was sometimes equal to 49 or 69, but most of the times 48.
The question is why these particular value ???
Is that a Unity behaviour to tell there is something wrong ?
Thanks for your time.