2018-12-31 23:16:28 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
namespace UnityEngine.UI.Extensions.Examples
|
2017-08-02 17:21:45 +08:00
|
|
|
|
{
|
|
|
|
|
public class Example01ScrollViewCell : FancyScrollViewCell<Example01CellDto>
|
|
|
|
|
{
|
|
|
|
|
[SerializeField]
|
2019-03-08 02:11:51 +08:00
|
|
|
|
Animator animator = null;
|
2017-08-02 17:21:45 +08:00
|
|
|
|
[SerializeField]
|
2019-03-08 02:11:51 +08:00
|
|
|
|
Text message = null;
|
2017-08-02 17:21:45 +08:00
|
|
|
|
|
2018-12-31 23:16:28 +08:00
|
|
|
|
static readonly int scrollTriggerHash = Animator.StringToHash("scroll");
|
2017-08-02 17:21:45 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-12-31 23:16:28 +08:00
|
|
|
|
/// Updates the content.
|
2017-08-02 17:21:45 +08:00
|
|
|
|
/// </summary>
|
2018-12-31 23:16:28 +08:00
|
|
|
|
/// <param name="itemData">Item data.</param>
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public override void UpdateContent(Example01CellDto itemData)
|
|
|
|
|
{
|
|
|
|
|
message.text = itemData.Message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-12-31 23:16:28 +08:00
|
|
|
|
/// Updates the position.
|
2017-08-02 17:21:45 +08:00
|
|
|
|
/// </summary>
|
2018-12-31 23:16:28 +08:00
|
|
|
|
/// <param name="position">Position.</param>
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public override void UpdatePosition(float position)
|
|
|
|
|
{
|
2018-12-31 23:16:28 +08:00
|
|
|
|
currentPosition = position;
|
2017-08-02 17:21:45 +08:00
|
|
|
|
animator.Play(scrollTriggerHash, -1, position);
|
|
|
|
|
animator.speed = 0;
|
|
|
|
|
}
|
2018-12-31 23:16:28 +08:00
|
|
|
|
|
|
|
|
|
// GameObject が非アクティブになると Animator がリセットされてしまうため
|
|
|
|
|
// 現在位置を保持しておいて OnEnable のタイミングで現在位置を再設定します
|
|
|
|
|
float currentPosition = 0;
|
|
|
|
|
void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
UpdatePosition(currentPosition);
|
|
|
|
|
}
|
2017-08-02 17:21:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|