public void AddWordButtonValue(WordButton butt) { if (nbWord == nbMaxWord) { return; } nbWord++; UnityEngine.Debug.Log(butt.word); sentenceWord.Add(butt.word); if (butt.FindSelectableOnRight() != null) { butt.FindSelectableOnRight().Select(); } else if (butt.FindSelectableOnLeft() != null) { butt.FindSelectableOnLeft().Select(); } else if (butt.FindSelectableOnUp() != null) { butt.FindSelectableOnUp().Select(); } else if (butt.FindSelectableOnDown() != null) { butt.FindSelectableOnDown().Select(); } butt.transform.SetParent(answerLine); UnityEngine.UI.Navigation nav = butt.navigation; nav.mode = UnityEngine.UI.Navigation.Mode.None; butt.navigation = nav; butt.submitted = true; }
private void OnBitLengthButtonPressed(object parameter) { string buttonId = parameter.ToString(); QwordButton.Visibility = Visibility.Collapsed; DwordButton.Visibility = Visibility.Collapsed; WordButton.Visibility = Visibility.Collapsed; ByteButton.Visibility = Visibility.Collapsed; if (buttonId == "0") { Model.ValueBitLength = BitLength.BitLengthDWord; DwordButton.Visibility = Visibility.Visible; DwordButton.Focus(FocusState.Programmatic); } else if (buttonId == "1") { Model.ValueBitLength = BitLength.BitLengthWord; WordButton.Visibility = Visibility.Visible; WordButton.Focus(FocusState.Programmatic); } else if (buttonId == "2") { Model.ValueBitLength = BitLength.BitLengthByte; ByteButton.Visibility = Visibility.Visible; ByteButton.Focus(FocusState.Programmatic); } else if (buttonId == "3") { Model.ValueBitLength = BitLength.BitLengthQWord; QwordButton.Visibility = Visibility.Visible; QwordButton.Focus(FocusState.Programmatic); } }
void AddWordButton(string word) { GameObject go = Instantiate(buttonPrefab); WordButton wb = go.GetComponent <WordButton>(); wb.SetWord(word); }
public void RemoveWordButtonValue(WordButton butt) { if (nbWord == 0) { return; } nbWord--; sentenceWord.Remove(butt.word); Transform toFeed = layouts[0]; for (int i = 1; i < layouts.Length; i++) { if (layouts[i].childCount < toFeed.childCount) { toFeed = layouts[i]; } } UnityEngine.UI.Navigation nav = butt.navigation; nav.mode = UnityEngine.UI.Navigation.Mode.Automatic; butt.navigation = nav; butt.transform.SetParent(toFeed); butt.submitted = false; }
public void RemoveLastWord() { if (nbWord == 0) { return; } Transform transf = answerLine.GetChild(answerLine.childCount - 1); WordButton wb = transf.GetComponent <WordButton>(); RemoveWordButtonValue(wb); }
public void DeleteLetter(WordButton buttonText) { if (Index - 1 > -1) { if (WordButtons[Index - 1] == buttonText && 0 < Index && WordButtons.Length + 1 > Index) { KeyButtons[buttonText.SavedIndex].Reactivate(); WordButtons[Index - 1].buttonText.text = ""; Index -= 1; } } }
public void StartMessage(int numMessage) { int currentLayout = 0; MessageInfo info = messages.messages[numMessage]; List <string> words = new List <string>(); words.AddRange(info.sentenceWords); words.AddRange(info.baitWords); for (int i = 0; i < layouts.Length; i++) { foreach (Transform child in layouts[i].transform) { Destroy(child.gameObject); } } int nbWordsPerLine = words.Count / layouts.Length + 1; int index = words.Count - 1; int nbWords = 0; bool isFirst = true; do { GameObject go = Instantiate(buttonPrefab); RectTransform rect = go.transform as RectTransform; rect.rotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, UnityEngine.Random.Range(-10, 10))); WordButton butt = go.GetComponent <WordButton>(); butt.SetWord(words[index]); if (isFirst) { butt.Select(); isFirst = false; } go.transform.SetParent(layouts[currentLayout]); nbWords++; if (nbWords == nbWordsPerLine) { currentLayout++; nbWords = 0; } words.RemoveAt(index); index = UnityEngine.Random.Range(0, words.Count); } while (words.Count != 0); currentMessage = numMessage; }