// Called when the cube is clicked on void OnMouseDown() { // Increase the cube's color index colorIndex++; // Modulus function to keep the color index from getting out of range // More info about modulus: https://msdn.microsoft.com/en-us/library/0w4e0fzs.aspx colorIndex %= colorCount; // Adds one to the click count clickCountSinceGrowth++; // Sets the color based on what value the controller returns colorer.material.color = controller.GetCubeColor(colorIndex); // Checks whether the cube should grow if (controller.CubeShouldGrow(clickCountSinceGrowth)) { // Calls the cube's grow function Grow(); // Reset the cube's click count clickCountSinceGrowth = 0; } }