com.unity.uiextensions/Examples/FancyScrollView/01_Basic/Example01ScrollViewCell.cs

41 lines
1.2 KiB
C#

namespace UnityEngine.UI.Extensions.Examples
{
public class Example01ScrollViewCell : FancyScrollViewCell<Example01CellDto>
{
[SerializeField]
Animator animator = null;
[SerializeField]
Text message = null;
readonly int scrollTriggerHash = Animator.StringToHash("scroll");
void Start()
{
var rectTransform = transform as RectTransform;
rectTransform.anchorMax = Vector2.one;
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchoredPosition3D = Vector3.zero;
UpdatePosition(0);
}
/// <summary>
/// セルの内容を更新します
/// </summary>
/// <param name="itemData"></param>
public override void UpdateContent(Example01CellDto itemData)
{
message.text = itemData.Message;
}
/// <summary>
/// セルの位置を更新します
/// </summary>
/// <param name="position"></param>
public override void UpdatePosition(float position)
{
animator.Play(scrollTriggerHash, -1, position);
animator.speed = 0;
}
}
}