upgrade
This commit is contained in:
@@ -93,7 +93,7 @@ public class UIScrollView : MonoBehaviour
|
||||
/// Strength of the spring dampening effect.
|
||||
/// </summary>
|
||||
|
||||
public float dampenStrength = 9f;
|
||||
public float dampenStrength = 5f;
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal scrollbar used for visualization.
|
||||
@@ -850,26 +850,26 @@ public class UIScrollView : MonoBehaviour
|
||||
|
||||
// Adjust the momentum
|
||||
if (dragEffect == DragEffect.None) mMomentum = Vector3.zero;
|
||||
else mMomentum = Vector3.Lerp(mMomentum, mMomentum + offset * (0.01f * momentumAmount), 0.67f);
|
||||
else mMomentum = Vector3.Lerp(mMomentum, mMomentum + offset * (0.02f * momentumAmount), 0.67f);
|
||||
|
||||
// Move the scroll view
|
||||
if (!iOSDragEmulation || dragEffect != DragEffect.MomentumAndSpring)
|
||||
{
|
||||
MoveAbsolute(offset);
|
||||
}
|
||||
MoveAbsolute(offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);
|
||||
|
||||
if (constraint.magnitude > 1f)
|
||||
{
|
||||
MoveAbsolute(offset * 0.5f);
|
||||
mMomentum *= 0.5f;
|
||||
MoveAbsolute(offset * 0.5f);
|
||||
mMomentum *= 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveAbsolute(offset);
|
||||
}
|
||||
MoveAbsolute(offset);
|
||||
}
|
||||
}
|
||||
|
||||
// We want to constrain the UI to be within bounds
|
||||
@@ -877,10 +877,11 @@ public class UIScrollView : MonoBehaviour
|
||||
mPanel.clipping != UIDrawCall.Clipping.None &&
|
||||
dragEffect != DragEffect.MomentumAndSpring)
|
||||
{
|
||||
InvalidateBounds();
|
||||
RestrictWithinBounds(true, canMoveHorizontally, canMoveVertically);
|
||||
}
|
||||
|
||||
if (onDragmMove != null)
|
||||
if (onDragmMove != null)
|
||||
onDragmMove();
|
||||
}
|
||||
}
|
||||
@@ -908,7 +909,8 @@ public class UIScrollView : MonoBehaviour
|
||||
/// Apply the dragging momentum.
|
||||
/// </summary>
|
||||
|
||||
void LateUpdate ()
|
||||
//void LateUpdate()
|
||||
void Update ()
|
||||
{
|
||||
if (!Application.isPlaying) return;
|
||||
float delta = RealTime.deltaTime;
|
||||
@@ -949,25 +951,27 @@ public class UIScrollView : MonoBehaviour
|
||||
{
|
||||
if (mMomentum.magnitude > 0.0001f || mScroll != 0f)
|
||||
{
|
||||
float factor = 0.01f; // 0.05f
|
||||
if (movement == Movement.Horizontal)
|
||||
{
|
||||
mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, 0f, 0f));
|
||||
mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * factor, 0f, 0f));
|
||||
}
|
||||
else if (movement == Movement.Vertical)
|
||||
{
|
||||
mMomentum -= mTrans.TransformDirection(new Vector3(0f, mScroll * 0.05f, 0f));
|
||||
mMomentum -= mTrans.TransformDirection(new Vector3(0f, mScroll * factor, 0f));
|
||||
}
|
||||
else if (movement == Movement.Unrestricted)
|
||||
{
|
||||
mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, mScroll * 0.05f, 0f));
|
||||
mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * factor, mScroll * factor, 0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
mMomentum -= mTrans.TransformDirection(new Vector3(
|
||||
mScroll * customMovement.x * 0.05f,
|
||||
mScroll * customMovement.y * 0.05f, 0f));
|
||||
mScroll * customMovement.x * factor,
|
||||
mScroll * customMovement.y * factor, 0f));
|
||||
}
|
||||
mScroll = NGUIMath.SpringLerp(mScroll, 0f, 20f, delta);
|
||||
//mScroll = NGUIMath.SpringLerp(mScroll, 0f, 20f, delta);
|
||||
mScroll = NGUIMath.SpringLerp(mScroll, 0f, 5f, delta);
|
||||
|
||||
// Move the scroll view
|
||||
Vector3 offset = NGUIMath.SpringDampen(ref mMomentum, dampenStrength, delta);
|
||||
@@ -987,7 +991,8 @@ public class UIScrollView : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
RestrictWithinBounds(false, canMoveHorizontally, canMoveVertically);
|
||||
InvalidateBounds();
|
||||
RestrictWithinBounds(true, canMoveHorizontally, canMoveVertically);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1005,6 +1010,27 @@ public class UIScrollView : MonoBehaviour
|
||||
mShouldMove = false;
|
||||
if (onStoppedMoving != null)
|
||||
onStoppedMoving();
|
||||
|
||||
/*
|
||||
// Restrict the contents to be within the scroll view's bounds
|
||||
if (restrictWithinPanel && mPanel.clipping != UIDrawCall.Clipping.None)
|
||||
{
|
||||
if (NGUITools.GetActive(centerOnChild))
|
||||
{
|
||||
if (centerOnChild.nextPageThreshold != 0f)
|
||||
{
|
||||
mMomentum = Vector3.zero;
|
||||
mScroll = 0f;
|
||||
}
|
||||
else centerOnChild.Recenter();
|
||||
}
|
||||
else
|
||||
{
|
||||
InvalidateBounds();
|
||||
RestrictWithinBounds(false, canMoveHorizontally, canMoveVertically);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user