public void LeftBoxSingleSelect(TeachHitObjectItem item) { if (m_LeftBoxCurrentItem != null) { m_LeftBoxCurrentItem.SetUnselect(); } m_LeftBoxCurrentItem = item; }
public void SelectWord(TeachHitObjectItem item) { if (m_CurrentSelectWord != null) { m_CurrentSelectWord.SetUnselect(); if (m_CurrentSelectWord.m_Index == item.m_Index) { m_CurrentSelectWord = null; return; } } m_CurrentSelectWord = item; }
public void SelectOneSentence(TeachHitObjectItem item) { if (m_CurrentSelectSentence != null) { m_CurrentSelectSentence.SetUnselect(); ClearSentenceContentBox(); if (m_CurrentSelectSentence.m_Index == item.m_Index) { return; } } m_CurrentSelectSentence = item; m_SentenceStartTime.text = m_Sentences[m_CurrentSelectSentence.m_Index - 1].m_StartTime.ToString(); m_SentenceEndTime.text = m_Sentences[m_CurrentSelectSentence.m_Index - 1].m_EndTime.ToString(); ShowOneSentence(); }
public void SelectSentence(TeachHitObjectItem item) { if (m_CurrentSelectSentence != null) { m_CurrentSelectSentence.SetUnselect(); ClearChildContent(m_WordContent.transform); if (m_CurrentSelectSentence.m_Index == item.m_Index) { m_CurrentSelectSentence = null; return; } } m_CurrentSelectSentence = item; CreateWordContent(); }
void ShowOneSentence() { ClearChildContent(m_SentenceHOContent.transform); int startIndex = 0; m_SentenceHOContent.GetComponent <RectTransform>().sizeDelta = new Vector2(StartWidth, StartPosY + (Interval + ItemHeight) * m_HitObjects.Count); foreach (CO co in m_Sentences[m_CurrentSelectSentence.m_Index - 1].m_COList) { GameObject obj = Instantiate(ResourceLoadUtils.Load <GameObject>("TeachTool/HitObjectItem")); obj.transform.SetParent(m_SentenceHOContent.transform); obj.transform.localScale = Vector2.one; obj.GetComponent <RectTransform>().localPosition = new Vector3(ItemXPos, -StartPosY - (ItemHeight + Interval) * startIndex, 0); TeachHitObjectItem tho = obj.GetComponent <TeachHitObjectItem>(); tho.Init(this, TeachHitObjectItem.Type.RightBox, co.m_Index); tho.SetString(co.ToString()); startIndex++; } }
void CreateSentenceBoxContent() { ClearChildContent(m_SentenceContent.transform); int startIndex = 0; m_SentenceContent.GetComponent <RectTransform>().sizeDelta = new Vector2(StartWidth, StartPosY + (Interval + ItemHeight) * m_HitObjects.Count); foreach (CleanSentence cs in m_Sentences) { GameObject obj = Instantiate(ResourceLoadUtils.Load <GameObject>("TeachTool/HitObjectItem")); obj.transform.SetParent(m_SentenceContent.transform); obj.transform.localScale = Vector2.one; obj.GetComponent <RectTransform>().localPosition = new Vector3(ItemXPos, -StartPosY - (ItemHeight + Interval) * startIndex, 0); TeachHitObjectItem item = obj.GetComponent <TeachHitObjectItem>(); item.Init(this, TeachHitObjectItem.Type.Sentence, cs.m_Index); item.SetString(cs.ToString()); startIndex++; } }
//list中始终保证最多有两个元素 public void RightBoxSelect(TeachHitObjectItem item) { if (m_CurrentSelectItemsInRightBox.Contains(item)) { item.SetUnselect(); m_CurrentSelectItemsInRightBox.Remove(item); } else if (m_CurrentSelectItemsInRightBox.Count == 0) { m_CurrentSelectItemsInRightBox.Add(item); } else if (m_CurrentSelectItemsInRightBox.Count == 1) { if (m_CurrentSelectItemsInRightBox[0].m_Index > item.m_Index) { m_CurrentSelectItemsInRightBox.Insert(0, item); } else { m_CurrentSelectItemsInRightBox.Add(item); } } else { if (m_CurrentSelectItemsInRightBox[0].m_Index > item.m_Index) { m_CurrentSelectItemsInRightBox[0].SetUnselect(); m_CurrentSelectItemsInRightBox.RemoveAt(0); m_CurrentSelectItemsInRightBox.Insert(0, item); } else { m_CurrentSelectItemsInRightBox[1].SetUnselect(); m_CurrentSelectItemsInRightBox.RemoveAt(1); m_CurrentSelectItemsInRightBox.Add(item); } } }