UISwipeableView is a simple UI components for implementing swipe views like Tinder. Since Only two card objects are generated, performance will not be reduced even if the number of data items increases.
Check out the demo for an example.
public class DemoCardData
{
public Color color;
}
public class SwipeableViewDemo : UISwipeableView<DemoCardData>
{
public void UpdateData(List<DemoCardData> data)
{
base.Initialize(data);
}
}
public class SwipeableCardDemo : UISwipeableCard<DemoCardData>
{
[SerializeField] private Image bg;
public override void UpdateContent(DemoCardData data)
{
bg.color = data.color;
}
}
public class DemoScene : MonoBehaviour
{
[SerializeField] private UISwipeableViewDemo swipeableView;
void Start()
{
var data = Enumerable.Range(0, 20)
.Select(i => new DemoCardData
{
color = new Color(Random.value, Random.value, Random.value, 1.0f)
})
.ToList();
swipeableView.UpdateData(data);
}
}
Unity 2018.3.11f1
MIT