static public MUITweenValue Begin(GameObject go, float duration, float toValue) { MUITweenValue comp = go.GetComponent <MUITweenValue>(); #if UNITY_FLASH if ((object)comp == null) { comp = (MUITweenValue)go.AddComponent <MUITweenValue>(); } #else if (comp == null) { comp = go.AddComponent <MUITweenValue>(); } #endif comp.mStarted = false; comp.duration = duration; comp.mFactor = 0f; comp.animationCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)); comp.enabled = true; comp.endValue = toValue; if (duration <= 0f) { comp.enabled = false; } return(comp); }
public void PlayReverse() { mSp = transform.GetComponent <UISprite>(); spriteHeight = mSp.localSize.y; mSp.onPostFill += OnPostFill; TweenHeight tween = TweenHeight.Begin(mSp, duration * .9f, (int)spriteHeight); mSp.alpha = 1; tween.from = (int)spriteHeight; tween.to = 0; tween.animationCurve = heightCurve; EventDelegate.Add(tween.onFinished, OnTweenFinish, true); tweenValue = MUITweenValue.Begin(gameObject, duration * .9f, 1f); tweenValue.startValue = 0f; tweenValue.endValue = 1f; tweenValue.animationCurve = alphaCurve; tweenValue.PlayForward(); timeCount = 0; isEnd = false; isChange = true; isReverse = true; //Invoke("ChangeAlphaAni", duration / 10f); }
void OnMenuClick(GameObject go) { if (isDrag) { return; } isDragOut = true; int index = int.Parse(go.name.Substring(6)) - 1; float amount = .25f * index + bezierValue; if (amount > 1) { amount = amount % 1f; } else if (amount < 0) { amount = amount % 1f + 1; } tweenValue = MUITweenValue.Begin(gameObject, .3f, 0f); tweenValue.CurveValue = bezierValue; tweenValue.startValue = bezierValue; if (amount < .5f) { tweenValue.endValue = bezierValue - amount; } else { tweenValue.endValue = bezierValue + (1 - amount); } if (tweenValue.startValue == tweenValue.endValue) { if (onSelectOneItem != null) { onSelectOneItem(index); isDragOut = false; } } else { if (onBeginRotation != null) { onBeginRotation(); } } tweenValue.PlayForward(); EventDelegate.Add(tweenValue.onFinished, OnTweenMenuFinish, true); }
// Use this for initialization void Start() { if (!Application.isPlaying) { if (bezierPoints.Count > 0 && bezierPoints[0] == null) { bezierPoints.Clear(); foreach (MUIBezierPoint point in gameObject.GetComponents <MUIBezierPoint>()) { bezierPoints.Add(point); } return; } MUIBezierPoint[] pts = gameObject.GetComponents <MUIBezierPoint>(); foreach (MUIBezierPoint point in pts) { DestroyImmediate(point); } foreach (MUIBezierPoint point in bezierPoints) { MUIBezierPoint p = gameObject.AddComponent <MUIBezierPoint>(); p.Copy(point); } return; } bezierPoints.Clear(); MUIBezierPoint[] points = gameObject.GetComponents <MUIBezierPoint>(); foreach (MUIBezierPoint point in points) { bezierPoints.Add(point); } tween = MUITweenValue.Begin(gameObject, duration, 1f); tween.startValue = 0f; tween.startDelay = startDelay; tween.style = style; tween.animationCurve = animationCurve; tween.onFinished.Clear(); tween.onFinished = onFinished; tween.Play(); //Debug.Log(bezierPoints.Count); }
void OnTweenValueFinish() { float amount = bezierValue; if (amount > 1) { amount = amount % 1f; } else if (amount < 0) { amount = amount % 1f + 1; } tweenValue = MUITweenValue.Begin(gameObject, .3f, 0f); tweenValue.CurveValue = bezierValue; tweenValue.startValue = bezierValue; float endValue = 0f; if (amount < (.25f * .5f)) { endValue = bezierValue - amount; } else if (amount < (.25f * .5f + .25f)) { endValue = bezierValue + (.25f - amount); } else if (amount < (.25f * .5f + .5f)) { endValue = bezierValue + (.5f - amount); } else if (amount < (.25f * .5f + .75f)) { endValue = bezierValue + (.75f - amount); } else if (amount < 1f) { endValue = bezierValue + (1 - amount); } tweenValue.endValue = endValue; tweenValue.PlayForward(); EventDelegate.Add(tweenValue.onFinished, OnSpringFinish, true); }
void OnPressItem(GameObject go, bool state) { if (state) { for (int i = 0; i < transform.childCount; i++) { if (go.name == transform.GetChild(i).name) { checkItemAmount = .25f * i + bezierValue; } } checkItemAmount = IdentityBezierAmount(checkItemAmount); preBezierValue = bezierValue; isDragOut = false; isDrag = false; } else if (isDrag) { isDragOut = true; tweenValue = MUITweenValue.Begin(gameObject, .3f, 0f); tweenValue.CurveValue = bezierValue; tweenValue.startValue = bezierValue; if (preBezierValue > bezierValue) { tweenValue.endValue = bezierValue - Mathf.Abs(mDelta * 2); } else { tweenValue.endValue = bezierValue + Mathf.Abs(mDelta * 2); } tweenValue.PlayForward(); EventDelegate.Add(tweenValue.onFinished, OnTweenValueFinish, true); } }