//Function for the clear all button. clears letters and sets the amount of slots to the initial one if there were extra. public void ClearAll() { FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/clearAll"); for (int i = 0; i < slotsParent.childCount; i++) { if (slotsParent.GetChild(i).childCount > 1) { GameObject letter = slotsParent.GetChild(i).transform.GetChild(1).gameObject; LetterDragHandler handler = letter.GetComponent <LetterDragHandler>(); if (CheckIfVowel(letter)) { handler.Remove(true); } else { handler.Remove(false); } } } if (slotsParent.childCount > amountOfSlots) { for (int i = slotsParent.childCount; i-- > amountOfSlots;) { GameObject slot = slotsList.Last().gameObject; Destroy(slot); slotsList.Remove(slot); } } GreyOutLetters(0, false); x = 0; }
//Function for the backspace public void RemoveLetter() { if (amountOfSlots != AvailableSlots()) { FMODUnity.RuntimeManager.PlayOneShot("event:/SFX/backspace"); if (LetterToDisable() != null) { GameObject letter = LetterToDisable(); LetterDragHandler handler = letter.GetComponent <LetterDragHandler>(); if (CheckIfVowel(letter)) { handler.Remove(true); } else { handler.Remove(false); } if (slotsParent.childCount > amountOfSlots) { GameObject lastItem = slotsList.Last().gameObject; Destroy(lastItem); slotsList.Remove(lastItem); } } } if (AvailableSlots() == amountOfSlots - 1) { GreyOutLetters(0, false); x = 0; } Debug.Log("X: " + x); Debug.Log("LastIndex" + lastIndex); }