private ScrollListItem CreatItemType(T item) { GameObject gameObject = _itemPool.Instantiate(_scrollArea.content.transform); IScrollListItem <T> newItem = gameObject.GetComponent <IScrollListItem <T> >(); newItem.Init(item); return(new ScrollListItem(newItem)); }
public static VisualEffect Instantiate([NotNull] VisualEffect prefab, Vector3 position, Quaternion rotation, Vector3 scale, [CanBeNull] Transform parent) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) GameObject val = (s_pool != null) ? s_pool.Instantiate(prefab.get_gameObject(), position, rotation, parent) : ((null == parent) ? Object.Instantiate <GameObject>(prefab.get_gameObject(), position, rotation) : Object.Instantiate <GameObject>(prefab.get_gameObject(), position, rotation, parent)); Transform transform = val.get_transform(); Vector3 localScale = transform.get_localScale(); localScale.Scale(scale); transform.set_localScale(localScale); return(val.GetComponent <VisualEffect>()); }
private void UpdateLines(float deltaTime) { //keep lines in sync TMP_TextInfo textInfo = _textMesh.textInfo; float lineHeight = _lineHeight * _textMesh.fontSize; //Need to add new lines if (_lines.Length < textInfo.lineCount) { Image[] lines = new Image[textInfo.lineCount]; for (int i = 0; i < lines.Length; i++) { if (i < _lines.Length) { lines[i] = _lines[i]; } else { lines[i] = _linePrefabPool.Instantiate(_textMesh.rectTransform).GetComponent <Image>(); lines[i].rectTransform.pivot = new Vector2(0f, 0.5f); lines[i].rectTransform.anchorMin = new Vector2(0f, 0f); lines[i].rectTransform.anchorMax = new Vector2(0f, 0f); lines[i].rectTransform.sizeDelta = new Vector2(0f, lineHeight); } } _lines = lines; if (!_animated) { _lineIndex = textInfo.lineCount; } } //Need to remove lines else if (_lines.Length > textInfo.lineCount) { Image[] lines = new Image[textInfo.lineCount]; for (int i = 0; i < _lines.Length; i++) { if (i < textInfo.lineCount) { lines[i] = _lines[i]; } else { _linePrefabPool.Destroy(_lines[i].gameObject); } } _lines = lines; if (_lineIndex > textInfo.lineCount) { _lineIndex = textInfo.lineCount; _currentLineSpeed = _speed; } } //Update animations if (_animated && _lineIndex < _lines.Length && deltaTime > 0f) { RectTransform currentLine = _lines[_lineIndex].rectTransform; currentLine.anchoredPosition = GetLinePosition(textInfo.lineInfo[_lineIndex], out float lineWidth); float currentWidth = RectTransformUtils.GetWidth(currentLine); if (currentWidth < lineWidth) { _currentLineSpeed += _acceleration * deltaTime; currentWidth += _currentLineSpeed * deltaTime; if (currentWidth >= lineWidth) { currentWidth = lineWidth; _currentLinePauseTimer = _endOfLinePause; } } else { currentWidth = lineWidth; _currentLinePauseTimer -= deltaTime; if (_currentLinePauseTimer <= 0f) { _currentLineSpeed = _speed; _lineIndex++; } } currentLine.sizeDelta = new Vector2(currentWidth, lineHeight); } //Update shown lines for (int i = 0; i < Mathf.Min(_lines.Length, _lineIndex); i++) { _lines[i].rectTransform.anchoredPosition = GetLinePosition(textInfo.lineInfo[i], out float lineWidth); _lines[i].rectTransform.sizeDelta = new Vector2(lineWidth, lineHeight); _lines[i].color = _lineColor; } }
private void FindChanges(IList <T> items, out List <ScrollListItem> toAdd, out List <ScrollListItem> toRemove) { toAdd = new List <ScrollListItem>(); toRemove = new List <ScrollListItem>(_items); _items.Clear(); Vector2 pos = new Vector2(0f, -StartPadding); if (items != null) { for (int i = 0; i < items.Count; ++i) { ScrollListItem item = null; foreach (ScrollListItem button in toRemove) { if (button._item.GetData().Equals(items[i])) { _items.Add(button); toRemove.Remove(button); item = button; break; } } RectTransform transform; //If no item exists for this create a new one if (item == null) { GameObject gameObject = _itemPool.Instantiate(_scrollArea.content.transform); item = new ScrollListItem(gameObject.GetComponent <IScrollListItem <T> >()); item._item.OnShow(items[i]); item._lerp = 0.0f; item._state = ScrollListItem.State.FadingIn; item._targetPosition = pos; item._fromPosition = pos; transform = item._item.GetTransform(); transform.anchoredPosition = pos; item._item.SetFade(0.0f); _items.Add(item); toAdd.Add(item); } //Otherwise update existing else { transform = item._item.GetTransform(); if (item._targetPosition != pos) { item._targetPosition = pos; item._fromPosition = transform.anchoredPosition; item._state = ScrollListItem.State.Moving; item._lerp = 0.0f; item._item.SetFade(1.0f); } item._item.OnUpdate(items[i]); } pos.y -= transform.sizeDelta.y + ItemPadding; } } }