• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tinder UI for Unity

Unity-SwipeableView License

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.

screenshot1 screenshot2

Usage

Check out the demo for an example.

1. Create your data object.

public class DemoCardData
{
    public Color color;
}

2. Create SwipeableView by extends UISwipeableView.

public class SwipeableViewDemo : UISwipeableView<DemoCardData>
{
    public void UpdateData(List<DemoCardData> data)
    {
        base.Initialize(data);
    }
}

3. Create SwipeableCard by extends UISwipeableCard.

public class SwipeableCardDemo : UISwipeableCard<DemoCardData>
{
    [SerializeField] private Image bg;

    public override void UpdateContent(DemoCardData data)
    {
        bg.color = data.color;
    }
}

4. Pass data to the SwipeableView.

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);
    }
}

Environment

Unity 2018.3.11f1

License

MIT

Author

kiepng