Giter Club home page Giter Club logo

unity-swipeableview's Introduction

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

unity-swipeableview's People

Contributors

kiepng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

unity-swipeableview's Issues

Whats the suggested architecture for having multiple cards of different types?

I have a collection of ScriptableObjects that derive from a custom type (Card)
ei:

class BattleCard : Card
class ProfileCard : Card

I then start my prototype (and this framework) by calling:

public class CardGenerater : Singleton<CardGenerater>
{
	public List<Card> DataSet;

	public CustomSwipeableView view;

	void OnEnable()
	{
		view.UpdateData(DataSet);
	}
}

which calls:

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

An important note here: CardGenerater.DataSet contains ScriptableObjects of type BattleCard and ProfileCard (and in the future, other types too)
This functions correctly and as expected, cards display and data gets assigned, however, I'd like to have different prefabs for BattleCards and ProfileCards (because they are functionally different)

Does this currently support this? If so, how should it be implemented?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.