I just spend 2 hours bouncing my head against the wall trying to figure out what was going on with some scripts when I found it had to do with populating arrays:
var arr = = new Array();
function DoSomeStuff(){
// be sure the array is emtpty
arr.clear();
// some code to populate the array
// the array will look something like this (4,2,3,1)
..
}
Each time I run the scene in game view the function above is called at start up. But what I found is that actually the array doesn´t get cleared from the previous run. Each time it pushes the new array elements to the array. So after running the scene 3 times under the same circumstances the array above will look like (4,4,4,2,2,2,3,3,3,1,1,1).
Only when simply resaving one of the scripts in the project folder (even when not making any changes), the array gets cleared. Is this what is supposed to happen?