44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
/*
|
|
* FancyScrollView (https://github.com/setchi/FancyScrollView)
|
|
* Copyright (c) 2020 setchi
|
|
* Licensed under MIT (https://github.com/setchi/FancyScrollView/blob/master/LICENSE)
|
|
*/
|
|
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace FancyScrollView.Example01
|
|
{
|
|
class Cell : FancyCell<ItemData>
|
|
{
|
|
[SerializeField] Animator animator = default;
|
|
[SerializeField] TMP_Text message = default;
|
|
|
|
static class AnimatorHash
|
|
{
|
|
public static readonly int Scroll = Animator.StringToHash("scroll");
|
|
}
|
|
|
|
public override void UpdateContent(ItemData itemData)
|
|
{
|
|
message.text = itemData.Message;
|
|
}
|
|
|
|
public override void UpdatePosition(float position)
|
|
{
|
|
currentPosition = position;
|
|
|
|
if (animator.isActiveAndEnabled)
|
|
{
|
|
animator.Play(AnimatorHash.Scroll, -1, position);
|
|
}
|
|
|
|
animator.speed = 0;
|
|
}
|
|
float currentPosition = 0;
|
|
|
|
void OnEnable() => UpdatePosition(currentPosition);
|
|
}
|
|
}
|