Let’s continue with your ObjectLookup script’s OnMouseDown function.
5. Add the following beneath the previous code:
//now read through the remainder in pairs
//iterate through the array starting at element 2 and incrementing by 2
//as long as the counting variable i is less than the length of the array
for (var i = 2; i < readString.length; i= i + 2) {
print ("auxiliary object = " + readString[i]);
print (readString[i] + "'s new state = " + readString[i+1]);
}
} // close the for/in block
} // close the OnMouseDown function
6. Save the script.
To test, you will start with the one of the simpler states, 2, and work your way backward.
1. Click Play.
2. Select the LockPlate in the Hierarchy view.
3. In the Inspector, set the state variable to 2.
4. Pick the LockPlate in the Game window.
5. Look at the results in the Console, Figure 9-13.