void Start() { Screen.orientation = ScreenOrientation.Portrait; bestMovesText.text = "Best Moves: " + level; currMovesText.text = "Moves: " + movesCounter; int nowY = STEP; propellerArray = new Propeller[DIMENSION, DIMENSION]; for (int myLine = 0; myLine < DIMENSION; myLine++) { for (int i = 0; i < DIMENSION; i++) { Propeller newPropeller = Instantiate(PropellerPrefab, myCanvas.transform).GetComponent <Propeller>(); Vector2 myPos = new Vector2((startX + i) * STEP, nowY); newPropeller.setPosition(myPos); int first = myLine, second = i; newPropeller.GetComponent <Button>().onClick.AddListener(delegate { onClick(first, second); }); propellerArray[myLine, i] = newPropeller; } nowY -= STEP; } randomToggles(); }