Vector2 itemSizeFunc_2(int index) { DefaultScrollItemData sd = testData[index]; if (sd.name == "XXL") { return(new Vector2(300, 120)); } else if (sd.name == "XL") { return(new Vector2(250, 110)); } else if (sd.name == "L") { return(new Vector2(200, 100)); } else if (sd.name == "M") { return(new Vector2(150, 90)); } else // "S" { return(new Vector2(100, 80)); } }
void updateFunc(int index, RectTransform item) { DefaultScrollItemData data = testData[index]; item.gameObject.SetActive(true); item.transform.Find("Text").GetComponent <Text>().text = string.Format("{0}_{1}", data.name, index); }
Vector2 itemSizeFunc(int index) { TimeConsumingFunc(); DefaultScrollItemData sd = testData[index]; if (sd.name == "XXL") { return(new Vector2(300, 150)); } else if (sd.name == "XL") { return(new Vector2(300, 125)); } else if (sd.name == "L") { return(new Vector2(300, 100)); } else if (sd.name == "M") { return(new Vector2(300, 75)); } else // "S" { return(new Vector2(300, 50)); } }
void updateFunc(ScrollItem item, SObject data) { item.gameObject.SetActive(true); DefaultScrollItemData sd = (DefaultScrollItemData)data; item.transform.Find("Text").GetComponent <Text>().text = string.Format("{0}_{1}", sd.name, sd.id); }
void updateFunc_3(ScrollItem item, SObject data) { item.gameObject.SetActive(true); DefaultScrollItemData sd = (DefaultScrollItemData)data; item.GetComponent <Text>().text = GetLongTextByData(sd); }
void updateFunc_3(int index, RectTransform item) { DefaultScrollItemData data = testData[index]; item.gameObject.SetActive(true); item.GetComponent <Text>().text = GetLongTextByData(data); }
public void AppendRandomData() { DefaultScrollItemData newData = new DefaultScrollItemData() { name = GetRandomSizeString(), longString = GetRandomLongText() }; testData.Add(newData); UpdateAllScrollViewsIncrementally(); }
public void AddRandomData() { DefaultScrollItemData newData = new DefaultScrollItemData() { name = GetRandomSizeString(), longString = GetRandomLongText() }; testData.Insert(UnityEngine.Random.Range(0, testData.Count), newData); UpdateAllScrollViews(); }
void Start() { scrollView.SetUpdateFunc(updateFunc); scrollView.SetItemSizeFunc(itemSizeFunc); scrollView.SetItemCountFunc(itemCountFunc); scrollViewEx.SetUpdateFunc(updateFunc); scrollViewEx.SetItemSizeFunc(itemSizeFunc); scrollViewEx.SetItemCountFunc(itemCountFunc); int dataCount = 0; do { DefaultScrollItemData newData = new DefaultScrollItemData() { name = GetRandomSizeString() }; testData.Add(newData); }while (++dataCount < 50000); scrollView.UpdateData(false); scrollViewEx.UpdateData(false); }
public void AddRandomData() { DefaultScrollItemData newData = new DefaultScrollItemData() { name = GetRandomSizeString() }; testData.Insert(UnityEngine.Random.Range(0, testData.Count), newData); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); scrollView.UpdateData(true); stopwatch.Stop(); long time1 = stopwatch.ElapsedMilliseconds; stopwatch.Reset(); stopwatch.Start(); scrollViewEx.UpdateData(true); stopwatch.Stop(); long time2 = stopwatch.ElapsedMilliseconds; UnityEngine.Debug.Log($"cost time in ms: ScrollView:{time1} ScrollViewEx:{time2}"); }
void updateFunc_3(int index, RectTransform item) { DefaultScrollItemData data = testData[index]; item.GetComponent <Text>().text = data.longString; }
string GetLongTextByData(DefaultScrollItemData data) { return(string.Format("{0}->\n{1}\n", data.id, new string('A', data.id * 5))); }