void MakeButton(string caption, SimpleButton.ClickCallback callback) { int col = bttns.Count % numberOfColumns; int row = bttns.Count / numberOfColumns; int y = -row * spacingHeight; RectTransform column = columns[col]; SimpleButton bttn = Instantiate(prefabButton, columns[col]); bttn.Init(caption, callback); bttns.Add(bttn); if (buttonToFocusOn == null) { buttonToFocusOn = bttn; } RectTransform bttnTrans = bttn.transform as RectTransform; bttnTrans.anchorMin = new Vector2(0, 1); bttnTrans.anchorMax = new Vector2(1, 1); int marginLeft = (col == 0) ? 0 : gutterWidth; int marginRight = (col == numberOfColumns - 1) ? 0 : -gutterWidth; bttnTrans.anchoredPosition = new Vector2(0, y); bttnTrans.offsetMin = new Vector2(marginLeft, bttnTrans.offsetMin.y); bttnTrans.offsetMax = new Vector2(marginRight, bttnTrans.offsetMax.y); }
public override void OnReady() { ok_words.Clear(); wrong_words.Clear(); signal.SetActive(false); cards.Clear(); Utils.RemoveAllChildsIn(container); ok = 0; base.OnReady(); string story_id = Data.Instance.storiesData.activeContent.id; content = Data.Instance.gamesData.GetContent(story_id); StoriesData.Content story_content = Data.Instance.storiesData.activeContent; GamesData.Content gameDataContent = Data.Instance.gamesData.GetContent(story_content.id); List <string> arr = gameDataContent.GetContentFor(type, gameID); TextsData.Content tipContent = Data.Instance.daysData.GetTip("toca_empiezan_igual"); int id = 0; bool isOk = true; foreach (string text in arr) { if (text == "-" || text.Contains("-")) { isOk = false; } else { string _text = GetParsedString(text); if (isOk) { ok_words.Add(_text); } else { wrong_words.Add(_text); } SimpleButton sb = Instantiate(simonCard); sb.transform.localScale = Vector2.one; // string _text = GetParsedString(text); Sprite sprite = Data.Instance.assetsData.GetContent(_text).sprite; sb.Init(id, sprite, _text, OnClicked); cards.Add(sb); } id++; } Utils.Shuffle(cards); foreach (SimpleButton sb in cards) { sb.transform.SetParent(container); sb.transform.localScale = Vector2.one; } Events.OnCharacterSay(tipContent, OnTipDone, tipContent.character_type); }
void AddCard(string text) { SimpleButton sb = Instantiate(simonCard); sb.transform.localScale = Vector2.one; Sprite sprite = Data.Instance.assetsData.GetContent(text).sprite; sb.Init(id, sprite, text, OnClicked); cards.Add(sb); }