Git Product home page Git Product logo

enhancedscrollview's Introduction

EnhancedScrollView

Cool "3d" scoll view for Unity3D 4.x and 5.x version NGUI and UGUI support

Using Unity3d's AnimationCurve to finish this EnhancedScrollView.AnimationCurve is very powerful and useful tools in developing game,the player's jumping, camera's path and so on.

Features

  1. Click left right button to recenter item
  2. Click target to recenter and select item
  3. Drag feature: drag enhanceScrollview to recenter item
  4. Update item status with Curve horizontal time changing
  5. Edit control curves for scale, position, and "depth", you can add your own curve to control item other properties
  6. NGUI 2d, world 3d, and UGUI support

Curves In Project

  1. Position Curve. Control item's position.
  2. Scale Curve. Control item's scale
  3. "Depth" Curve. For determine item's back and front relationship, It's can be UIWidget's depth in NGUI(2D) or the Item's Z position value in 3D world

In developing task

  1. drag feature (Done)
  2. animation curve editor(you can type the value for the KeyFrame)
  3. UGUI example(Done)
  4. ......

How to use

Easy to make your own Enhance Item

  1. open NGUIEnhanceScrollView.unity for NGUI example
  2. open UGUIEnhanceScrollView.unity for UGUI example

Easy way to make better Curve: Copy EnhancedScrollView Component in example and paste it to your own TargetScrollView


/// 
/// NGUI Enhance item example
/// 
public class MyNGUIEnhanceItem : EnhanceItem
{
    private UITexture mTexture;
    ......
    // Set the item "depth" 2d or 3d
    protected override void SetItemDepth(float depthCurveValue, int depthFactor, float itemCount)
    {
        if (mTexture.depth != (int)Mathf.Abs(depthCurveValue * depthFactor))
            mTexture.depth = (int)Mathf.Abs(depthCurveValue * depthFactor);
    }

    // Item is centered
    public override void SetSelectState(bool isCenter)
    {
        if (mTexture == null)
            mTexture = this.GetComponent();
        if (mTexture != null)
            mTexture.color = isCenter ? Color.white : Color.gray;
    }
    ......
}


///
/// UGUI Enhance item example
///
public class MyUGUIEnhanceItem : EnhanceItem
{
    private Button uButton;
    private RawImage rawImage;
    ......
    private void OnClickUGUIButton()
    {
        OnClickEnhanceItem();
    }

    // Set the item "depth" 2d or 3d
    protected override void SetItemDepth(float depthCurveValue, int depthFactor, float itemCount)
    {
        curDepth = (int)(depthCurveValue * itemCount);
        this.transform.SetSiblingIndex(curDepth);
    }

    public override void SetSelectState(bool isCenter)
    {
        if (rawImage == null)
            rawImage = GetComponent();
        rawImage.color = isCenter ? Color.white : Color.gray;
    }
    ......
}

ScreenShot

screenshot

If you have some cool ideas or bugs just share with us or open issues

License

MIT

enhancedscrollview's People

Contributors

frideal avatar tinyantstudio 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  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

enhancedscrollview's Issues

it seems I found a bug

When I drag the card a very small distance on center left card ,the card change to the center but the changed center card is not become grey

可以支持数据多于UI的支持么?

比如我有50个需要显示的数据,但同时只能看到有限个比如3个或者5个这样。
那么就是让这3个或5个UI在移动的时候根据相应的数据进行正确刷新。否则像现在这样就会效果不对。

在UGUI例子中,如果把startCenterIndex设为1,初始显示会错乱

错乱图如下:
图片

因为最开始摆牌时(即EnhanceScrollView.cs的Start()),设置正中位置过于精确,会出现有SiblingIndex重复问题。

比如说:还是6张牌,最开始摆牌时,会出现一张牌在第6层,两张牌在第3层,一张牌在第1层,一张牌在第2层,一张牌在第0层。但在滑动牌组时,其实是每一张牌各占一层。
把EnhanceScrollView.cs中的Start()函数里这一句

 curHorizontalValue = 0.5f - curCenterItem.CenterOffSet;

改成下面这句即可,这样正中位置就会有些偏差。

 curHorizontalValue = 0.51f - curCenterItem.CenterOffSet;

(我没有NGUI,所以没有测试NGUI的例子。)

How to solve auto click event?

When I drag the uncentered card into the center. It triggered OnClickUGUIButton automatically. But I don't want to trigger this when I just drag over. Any suggestion?

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.