38 lines
871 B
C#
38 lines
871 B
C#
using UnityEngine;
|
|
|
|
[AddComponentMenu("NGUI/Tween/Spring Position")]
|
|
public class SpringPosition : MonoBehaviour
|
|
{
|
|
public delegate void OnFinished();
|
|
|
|
public Vector3 target = Vector3.zero;
|
|
|
|
public float strength = 10f;
|
|
|
|
public bool ignoreTimeScale;
|
|
|
|
public bool updateScrollView;
|
|
|
|
public OnFinished onFinished;
|
|
|
|
private float mThreshold;
|
|
|
|
public static SpringPosition Begin(GameObject go, Vector3 pos, float strength)
|
|
{
|
|
SpringPosition springPosition = go.GetComponent<SpringPosition>();
|
|
if (springPosition == null)
|
|
{
|
|
springPosition = go.AddComponent<SpringPosition>();
|
|
}
|
|
springPosition.target = pos;
|
|
springPosition.strength = strength;
|
|
springPosition.onFinished = null;
|
|
if (!springPosition.enabled)
|
|
{
|
|
springPosition.mThreshold = 0f;
|
|
springPosition.enabled = true;
|
|
}
|
|
return springPosition;
|
|
}
|
|
}
|