Unity Swipeable View by kiepng - 5

Games & ProjectsGUI

Tinder UI for Unity

Unity 2018.3.11f1MIT LicenseUpdated 2 years agoCreated on April 18th, 2018
Go to source

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

Show all projects by kiepng