今天试了下NGUI的Scroll View ,功能还是很不错的
对于这样的拖动式UI,很多人喜欢在下面加小圆点,使用UICenterOnChild居中对齐,就像安卓手机上常见的那种
对于这样的小圆点该怎么去设计呢?
一个做法是判断位置,拖动时Scroll View所在的GameObject位置是会跟着变化的
然而这是一个很笨的办法
打开NGUI的源代码,看看有什么好东西
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2014 Tasharen Entertainment
//----------------------------------------------
using UnityEngine;
/// <summary>
/// Ever wanted to be able to auto-center on an object within a draggable panel?
/// Attach this script to the container that has the objects to center on as its children.
/// </summary>
[AddComponentMenu("NGUI/Interaction/Center Scroll View on Child")]
public class UICenterOnChild : MonoBehaviour
{
/// <summary>
/// The strength of the spring.
/// </summary>
public float springStrength = 8f;
/// <summary>
/// If set to something above zero, it will be possible to move to the next page after dragging past the specified threshold.
/// </summary>
public float nextPageThreshold = 0f;
/// <summary>
/// Callback to be triggered when the centering operation completes.
/// </summary>
public SpringPanel.OnFinished onFinished;
UIScrollView mScrollView;