private void SpawnNumbers() { actualNumbersText = new string[numberOfActualNumbers]; for (int i = 0; i < numberOfActualNumbers; i++) { int numberNum = Mathf.Abs(numberOfActualNumbers - i) - 1; string s = /* number.textMesh.text = */ ((numberNum > 9) ? numberNum.ToString() : "0" + numberNum.ToString()); //Debug.Log("i = " + i + "number = " + s); actualNumbersText[i] = s; } rotatableNumbers = new RotatableNumber[numberOfWheelNumbers]; for (int i = 0; i < numberOfWheelNumbers; i++) { RotatableNumber number = Instantiate(rotatableNumberPreFab); Transform numberTransform = number.transform; numberTransform.position = this.transform.position; numberTransform.rotation = Quaternion.Euler((i + 1) * angleIncrement, 0, 0);//TODO:cheap fix might damage stuff numberTransform.position -= (numberTransform.forward) * numberDistanceFromBase; numberTransform.SetParent(myTransform); // (numberNum > 9) ? numberNum.ToString() : "0" + numberNum.ToString(); number.textMesh.fontSize = textSize; rotatableNumbers[i] = number; } }
private void UpdateTexts() { bool testColours = false; if (testColours) { for (int i = 0; i < numberOfWheelNumbers; i++) { RotatableNumber rotatableNumber = rotatableNumbers[i]; rotatableNumber.textMesh.color = Color.white; } } for (int i = -5; i < 6; i++) //TODO: beutify { int myActualNumberIndex = actualIndex + i; if (myActualNumberIndex >= numberOfActualNumbers) { myActualNumberIndex -= numberOfActualNumbers; //-1+i; } else if (myActualNumberIndex < 0) { myActualNumberIndex += numberOfActualNumbers; } int myWheelNumberIndex = wheelIndex + i; if (myWheelNumberIndex >= numberOfWheelNumbers) { // myWheelNumberIndex = 0; myWheelNumberIndex -= numberOfWheelNumbers;// -1 + i; } else if (myWheelNumberIndex < 0) { myWheelNumberIndex += (numberOfWheelNumbers); } // int absI = Math.Abs(i); RotatableNumber rotatableNumber = rotatableNumbers[myWheelNumberIndex]; rotatableNumber.textMesh.text = actualNumbersText[myActualNumberIndex]; if (testColours) { Color colour = Color.white; switch (i) { case -2: colour = Color.blue; break; case -1: colour = Color.magenta; break; case 0: colour = Color.red; break; case 1: colour = Color.yellow; break; case 2: colour = Color.green; break; } rotatableNumber.textMesh.color = colour; } } }