private void OnWordTabDeleteClickedEvent(WordTextTab tab) { string[] wordList = currentData.GetSectionByLanguage(currentLanguageSelected).Words.ToArray(); int indexTab = wordList.GetIndexOf(tab.BaseWord); foreach (WordListSectionData section in currentData.AllWordListDatas) { section.Words.RemoveAt(indexTab); } SetWordTabs(); }
private void SetWordTabs() { WordListSectionData sData = currentData.GetSectionByLanguage(currentLanguageSelected); int listAmount = sData.Words.Count; float space = 10.0f; RectTransform rt = wordTabPrefab.transform as RectTransform; contentHolder.sizeDelta = new Vector2(contentHolder.sizeDelta.x, Mathf.Abs(textTabsHolder.localPosition.y) + (listAmount * space + (listAmount + 1) * rt.sizeDelta.y) + space); CleanAllWordTabs(); for (int i = 0; i <= listAmount; i++) { if (i != listAmount) { WordTextTab w = null; if (currentLanguageSelected == FullWordListData.BASE_LANGUAGE) { w = GameObject.Instantiate <WordTextTab>(wordTabPrefab); w.DeleteClickedEvent += OnWordTabDeleteClickedEvent; w.SetChangeableWord(currentData.GetSectionByLanguage(FullWordListData.BASE_LANGUAGE).Words[i]); } else { WordTextTabTranslation wt = GameObject.Instantiate <WordTextTabTranslation>(wordTabTranslationPrefab); w = wt; wt.BasewordTextfield.text = currentData.GetSectionByLanguage(FullWordListData.BASE_LANGUAGE).Words[i]; wt.SetChangeableWord(currentData.GetSectionByLanguage(currentLanguageSelected).Words[i]); } rt = w.transform as RectTransform; w.Id.text = (i + 1).ToString() + ":"; w.TabTextModifiedEvent += OnTabTextModifiedEvent; allActiveTabs.Add(w); } else { rt = createLanugageWordTabButton.transform as RectTransform; if (currentLanguageSelected == FullWordListData.BASE_LANGUAGE) { rt.gameObject.SetActive(true); } else { rt.gameObject.SetActive(false); } } rt.SetParent(textTabsHolder, false); rt.localPosition = new Vector3(rt.position.x, 0 - (((((RectTransform)wordTabPrefab.transform).sizeDelta.y) + space) * i), rt.position.z); } }
private void OnTabTextModifiedEvent(WordTextTab tab) { SetWordTabsInData(); }