/// <summary> /// 物品从小到大 /// </summary> /// <param name="Icon"></param> private void IconMinToMax(Image Icon) { DOTween.To(() => Icon.transform.localScale, size => Icon.transform.localScale = size, Vector3.one * 0.8f, 0.5f).SetEase(Ease.Linear); }
public override void build(SequenceControl seq, Track track, int index, UnityEngine.Object obj) { //allow tracks with just one key if (track.keys.Count == 1) { interp = Interpolation.None; } else if (canTween) { //invalid or in-between keys if (endFrame == -1) { return; } if (interp == Interpolation.Curve && path.Length <= 1) { return; } } Transform target = obj as Transform; var transParent = target.parent; Rigidbody body = target.GetComponent <Rigidbody>(); Rigidbody2D body2D = !body?target.GetComponent <Rigidbody2D>() : null; int frameRate = seq.take.frameRate; var rotTrack = (RotationEulerTrack)track; var axis = rotTrack.axis; float timeLength = getTime(frameRate);//1.0f / frameRate; switch (interp) { case Interpolation.None: if (axis == AxisFlags.X) { float _x = rotation.x; TweenerCore <float, float, TWeenPlugNoneOptions> tweenX; if (body) { tweenX = DOTween.To(new TweenPlugValueSet <float>(), () => target.localEulerAngles.x, (x) => { var a = target.localEulerAngles; body.rotation = Quaternion.Euler(x, a.y, a.z) * transParent.rotation; }, _x, timeLength); } else { tweenX = DOTween.To(new TweenPlugValueSet <float>(), () => target.localEulerAngles.x, (x) => { var a = target.localEulerAngles; a.x = x; target.localEulerAngles = a; }, _x, timeLength); } seq.Insert(this, tweenX); } else if (axis == AxisFlags.Y) { float _y = rotation.y; TweenerCore <float, float, TWeenPlugNoneOptions> tweenY; if (body) { tweenY = DOTween.To(new TweenPlugValueSet <float>(), () => target.localEulerAngles.y, (y) => { var a = target.localEulerAngles; body.rotation = Quaternion.Euler(a.x, y, a.z) * transParent.rotation; }, _y, timeLength); } else { tweenY = DOTween.To(new TweenPlugValueSet <float>(), () => target.localEulerAngles.y, (y) => { var a = target.localEulerAngles; a.y = y; target.localEulerAngles = a; }, _y, timeLength); } seq.Insert(this, tweenY); } else if (axis == AxisFlags.Z) { float _z = rotation.z; TweenerCore <float, float, TWeenPlugNoneOptions> tweenZ; if (body2D) { tweenZ = DOTween.To(new TweenPlugValueSet <float>(), () => target.localEulerAngles.z, (z) => { body2D.rotation = z + transParent.eulerAngles.z; }, _z, timeLength); } else if (body) { tweenZ = DOTween.To(new TweenPlugValueSet <float>(), () => target.localEulerAngles.z, (z) => { var a = target.localEulerAngles; body.rotation = Quaternion.Euler(a.x, a.y, z) * transParent.rotation; }, _z, timeLength); } else { tweenZ = DOTween.To(new TweenPlugValueSet <float>(), () => target.localEulerAngles.z, (z) => { var a = target.localEulerAngles; a.z = z; target.localEulerAngles = a; }, _z, timeLength); } seq.Insert(this, tweenZ); } else if (axis == AxisFlags.All) { TweenerCore <Vector3, Vector3, TWeenPlugNoneOptions> tweenV; if (body2D) { tweenV = DOTween.To(new TweenPlugValueSet <Vector3>(), () => target.localEulerAngles, (r) => { body2D.rotation = r.z + transParent.eulerAngles.z; }, rotation, timeLength); } else if (body) { tweenV = DOTween.To(new TweenPlugValueSet <Vector3>(), () => target.localEulerAngles, (r) => { body.rotation = Quaternion.Euler(r) * transParent.rotation; }, rotation, timeLength); } else { tweenV = DOTween.To(new TweenPlugValueSet <Vector3>(), () => target.localEulerAngles, (r) => { target.localEulerAngles = r; }, rotation, timeLength); } seq.Insert(this, tweenV); } else { TweenerCore <Vector3, Vector3, TWeenPlugNoneOptions> tweenV; DOGetter <Vector3> getter = () => { var ret = rotation; var rot = target.localEulerAngles; if ((axis & AxisFlags.X) != AxisFlags.None) { ret.x = rot.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { ret.y = rot.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { ret.z = rot.z; } return(ret); }; if (body2D) { tweenV = DOTween.To(new TweenPlugValueSet <Vector3>(), getter, (r) => { if ((axis & AxisFlags.Z) != AxisFlags.None) { body2D.rotation = r.z + transParent.eulerAngles.z; } }, rotation, timeLength); } else if (body) { tweenV = DOTween.To(new TweenPlugValueSet <Vector3>(), getter, (r) => { var rot = target.localEulerAngles; if ((axis & AxisFlags.X) != AxisFlags.None) { rot.x = r.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { rot.y = r.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { rot.z = r.z; } body.rotation = Quaternion.Euler(rot) * transParent.rotation; }, rotation, timeLength); } else { tweenV = DOTween.To(new TweenPlugValueSet <Vector3>(), getter, (r) => { var rot = target.localEulerAngles; if ((axis & AxisFlags.X) != AxisFlags.None) { rot.x = r.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { rot.y = r.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { rot.z = r.z; } target.localEulerAngles = rot; }, rotation, timeLength); } seq.Insert(this, tweenV); } break; case Interpolation.Linear: Vector3 endRotation = (track.keys[index + 1] as RotationEulerKey).rotation; Tweener tween; if (axis == AxisFlags.X) { if (body) { tween = DOTween.To(new FloatPlugin(), () => rotation.x, (x) => { var a = target.localEulerAngles; body.MoveRotation(Quaternion.Euler(x, a.y, a.z) * transParent.rotation); }, endRotation.x, timeLength); } else { tween = DOTween.To(new FloatPlugin(), () => rotation.x, (x) => { var a = target.localEulerAngles; a.x = x; target.localEulerAngles = a; }, endRotation.x, timeLength); } } else if (axis == AxisFlags.Y) { if (body) { tween = DOTween.To(new FloatPlugin(), () => rotation.y, (y) => { var a = target.localEulerAngles; body.MoveRotation(Quaternion.Euler(a.x, y, a.z) * transParent.rotation); }, endRotation.y, timeLength); } else { tween = DOTween.To(new FloatPlugin(), () => rotation.y, (y) => { var a = target.localEulerAngles; a.y = y; target.localEulerAngles = a; }, endRotation.y, timeLength); } } else if (axis == AxisFlags.Z) { if (body2D) { tween = DOTween.To(new FloatPlugin(), () => rotation.z, (z) => { body2D.rotation = z + transParent.eulerAngles.z; }, endRotation.z, timeLength); } else if (body) { tween = DOTween.To(new FloatPlugin(), () => rotation.z, (z) => { var a = target.localEulerAngles; body.MoveRotation(Quaternion.Euler(a.x, a.y, z) * transParent.rotation); }, endRotation.z, timeLength); } else { tween = DOTween.To(new FloatPlugin(), () => rotation.z, (z) => { var a = target.localEulerAngles; a.z = z; target.localEulerAngles = a; }, endRotation.z, timeLength); } } else if (axis == AxisFlags.All) { if (body2D) { tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => rotation, (r) => body2D.MoveRotation(r.z + transParent.eulerAngles.z), endRotation, timeLength); } else if (body) { tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => rotation, (r) => body.MoveRotation(Quaternion.Euler(r) * transParent.rotation), endRotation, timeLength); } else { tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => rotation, (r) => target.localEulerAngles = r, endRotation, timeLength); } } else { if (body2D) { tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => rotation, (r) => { if ((axis & AxisFlags.Z) != AxisFlags.None) { body2D.MoveRotation(r.z + transParent.eulerAngles.z); } }, endRotation, timeLength); } else if (body) { tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => rotation, (r) => { var rot = target.localEulerAngles; if ((axis & AxisFlags.X) != AxisFlags.None) { rot.x = r.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { rot.y = r.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { rot.z = r.z; } body.MoveRotation(Quaternion.Euler(rot) * transParent.rotation); }, endRotation, timeLength); } else { tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => rotation, (r) => { var rot = target.localEulerAngles; if ((axis & AxisFlags.X) != AxisFlags.None) { rot.x = r.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { rot.y = r.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { rot.z = r.z; } target.localEulerAngles = rot; }, endRotation, timeLength); } } if (hasCustomEase()) { tween.SetEase(easeCurve); } else { tween.SetEase(easeType, amplitude, period); } seq.Insert(this, tween); break; case Interpolation.Curve: var pathTween = GetPathTween(frameRate); if (axis == AxisFlags.X) { if (body) { pathTween.setter = (x) => { var a = target.localEulerAngles; body.MoveRotation(Quaternion.Euler(x.x, a.y, a.z) * transParent.rotation); }; pathTween.SetTarget(body); } else { pathTween.setter = (x) => { var a = target.localEulerAngles; a.x = x.x; target.localEulerAngles = a; }; pathTween.SetTarget(target); } } else if (axis == AxisFlags.Y) { if (body) { pathTween.setter = (x) => { var a = target.localEulerAngles; body.MoveRotation(Quaternion.Euler(a.x, x.y, a.z) * transParent.rotation); }; pathTween.SetTarget(body); } else { pathTween.setter = (x) => { var a = target.localEulerAngles; a.y = x.y; target.localEulerAngles = a; }; pathTween.SetTarget(target); } } else if (axis == AxisFlags.Z) { if (body2D) { pathTween.setter = (x) => { body2D.rotation = x.z + transParent.eulerAngles.z; }; pathTween.SetTarget(body2D); } else if (body) { pathTween.setter = (x) => { var a = target.localEulerAngles; body.MoveRotation(Quaternion.Euler(a.x, a.y, x.z) * transParent.rotation); }; pathTween.SetTarget(body); } else { pathTween.setter = (x) => { var a = target.localEulerAngles; a.z = x.z; target.localEulerAngles = a; }; pathTween.SetTarget(target); } } else if (axis == AxisFlags.All) { if (body2D) { pathTween.setter = (r) => body2D.MoveRotation(r.z + transParent.eulerAngles.z); pathTween.SetTarget(body2D); } else if (body) { pathTween.setter = (r) => body.MoveRotation(Quaternion.Euler(r) * transParent.rotation); pathTween.SetTarget(body); } else { pathTween.setter = (r) => target.localEulerAngles = r; pathTween.SetTarget(target); } } else { if (body2D) { pathTween.setter = (r) => { if ((axis & AxisFlags.Z) != AxisFlags.None) { body2D.MoveRotation(r.z + transParent.eulerAngles.z); } }; pathTween.SetTarget(body2D); } else if (body) { pathTween.setter = (r) => { var rot = target.localEulerAngles; if ((axis & AxisFlags.X) != AxisFlags.None) { rot.x = r.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { rot.y = r.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { rot.z = r.z; } body.MoveRotation(Quaternion.Euler(rot) * transParent.rotation); }; pathTween.SetTarget(body); } else { pathTween.setter = (r) => { var rot = target.localEulerAngles; if ((axis & AxisFlags.X) != AxisFlags.None) { rot.x = r.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { rot.y = r.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { rot.z = r.z; } target.localEulerAngles = rot; }; pathTween.SetTarget(target); } } if (hasCustomEase()) { pathTween.SetEase(easeCurve); } else { pathTween.SetEase(easeType, amplitude, period); } seq.Insert(this, pathTween); break; } }
public void HidePanel(float delay) { DOTween.To(() => CanvasGroup.alpha, x => CanvasGroup.alpha = x, 0, 0.1f).SetDelay(delay).OnComplete(() => { Destroy(gameObject, 1); }); ItemData = null; }
public static Tweener DOTextInt(this Text text, int initialValue, int finalValue, float duration, Func <int, string> convertor) { return(DOTween.To(() => initialValue, it => text.text = convertor(it), finalValue, duration)); }
public static Tweener DOTextDouble(this Text text, double initialValue, double finalValue, float duration, Func <double, string> convertor) { return(DOTween.To(() => initialValue, it => text.text = convertor(it), finalValue, duration)); }
void UpdateFillTop(float endValue) { float beginValue = fillMiddle.fillAmount; DOTween.To(() => beginValue, x => beginValue = x, endValue, 0.5f); }
private void Start() { _percentage = GetComponent <TextMeshProUGUI>(); _options = DOTween.To(() => _percentage.text, x => _percentage.text = x, (0).ToString(), 0); }
public static IObservable <Unit> TweenTo(this IReactiveProperty <TimeSpan?> This, TimeSpan target, float duration, Ease ease = Ease.Linear, bool completeTweenOnDispose = false) => This.TweenTo(() => DOTween.To(() => This.Value?.Ticks ?? 0, x => This.Value = TimeSpan.FromTicks(x), target.Ticks, duration), ease, completeTweenOnDispose);
public static Tweener ToAlpha(DOGetter <Color> getter, DOSetter <Color> setter, float endValue, float duration) { var color = getter(); return(DOTween.To(() => color.a, x => setter(new Color(color.r, color.g, color.b, x)), endValue, duration)); }
private void Update() { // SHIP HEIGHT CurrentGains = (Regen - othersCount * DecreasingHeightByOthers); shipHeight += CurrentGains * Time.deltaTime; altitudeText.text = ((int)shipHeight).ToString(); if (gameOver) { return; } if (score >= maxDistance) { EndGame(); } if (Input.GetKeyDown(KeyCode.Escape)) { if (gameIsPaused) { ResumeGame(); } else { PauseGame(); } } // STUN SCREENSHAKE if (nextStun < Time.time) { nextStun = Time.time + StunInterval; audioManager.Play("wind"); PlayerController.Instance.stunned = true; VCFollowShake.SetActive(true); VCFollow.SetActive(false); dummyValue = 0f; DOTween.To(() => dummyValue, x => dummyValue = x, 1f, stunDuration).OnComplete(() => { VCFollow.SetActive(true); VCFollowShake.SetActive(false); PlayerController.Instance.stunned = false; }); } // SCORE score += Time.deltaTime * multiplicator; scoreText.text = ((int)score).ToString(); if (shipHeight < 100f) { audioManager.Stop("theme"); EndGame(); } if (!doom && friendCount < 1) { doom = true; onTopDied.Invoke(); } }
public static IObservable <Unit> TweenTo(this IReactiveProperty <float?> This, float target, float duration, Ease ease = Ease.Linear, bool completeTweenOnDispose = false) => This.TweenTo(() => DOTween.To(() => This.Value ?? 0f, x => This.Value = x, target, duration), ease, completeTweenOnDispose);
protected virtual void AnimateColors(int index, Color targetColor, float animationDuration, TweenParams tweenParams) { _tweenColor [index] = DOTween.To(() => _childWidgets[index].color, x => _childWidgets[index].color = x, targetColor, animationDuration).SetAs(tweenParams); }
protected virtual void OnCustomLongPress(bool[] args) { if (!_started) { Start(); } if (!isActivated && (LongPress || LongClick)) { if (!args [0] && args [1]) { if (string.IsNullOrEmpty(_deactivatedWarningMessageOverride)) { if (!string.IsNullOrEmpty(DefaultDeactivatedWarningMessage)) { WarningHandler.Instance.Warning(DefaultDeactivatedWarningMessage); } } else { WarningHandler.Instance.Warning(_deactivatedWarningMessageOverride); } } } if (!isActivated) { return; } if (SupportDoubleClick && args[0]) { if (_tooFastClick) { return; } } if (LongClick) { OnLongClick(args[0]); } if (!LongPress) { return; } _callbackRegistered = false; StopTween(); if (args[0]) { _currentAnimationDuration = AnimationDuration; if (HasScaleAnimation) { _tweenScale = DOTween.To(() => transform.localScale, x => transform.localScale = x, _hoveredScale, _currentAnimationDuration).SetAs(_tweenParams); } if (HasColorAnimation) { for (byte i = 0; i < _defaultColor.Length; i++) { AnimateColors(i, _hoveredColor[i], _currentAnimationDuration, _tweenParams); } } if (HasHighlightAnimation) { _tweenHighlight = DOTween.To(() => HighlightSprite.alpha, x => HighlightSprite.alpha = x, 1f, _currentAnimationDuration).SetAs(_tweenParams); } if (_hasDownSound) { MasterAudio.PlaySoundAndForget(_downSoundName); } } else { if (args[1]) { _currentAnimationDuration = AnimationDuration * 0.5f; if (HasScaleAnimation) { _tweenScale = DOTween.To(() => transform.localScale, x => transform.localScale = x, _pressedScale, _currentAnimationDuration).SetAs(_callbackRegistered ? _tweenParams : _tweenParamsCallback); if (!_callbackRegistered) { _callbackRegistered = true; } } if (HasColorAnimation) { for (byte i = 0; i < _defaultColor.Length; i++) { AnimateColors(i, _pressedColor[i], _currentAnimationDuration, _callbackRegistered ? _tweenParams : _tweenParamsCallback); } if (!_callbackRegistered) { _callbackRegistered = true; } } if (HasHighlightAnimation) { _tweenHighlight = DOTween.To(() => HighlightSprite.alpha, x => HighlightSprite.alpha = x, 1f, _currentAnimationDuration).SetAs(_callbackRegistered ? _tweenParams : _tweenParamsCallback); if (!_callbackRegistered) { _callbackRegistered = true; } } if (_hasClickSound) { MasterAudio.PlaySoundAndForget(_clickSoundName); } if ((UICamera.currentTouchID < 0 && UICamera.currentTouchID == -1) || UICamera.currentTouchID >= 0) { EventDelegate.Execute(onClick); } else if (UICamera.currentTouchID == -2) { EventDelegate.Execute(onLeftClick); } } else { _currentAnimationDuration = AnimationDuration; if (HasScaleAnimation) { _tweenScale = DOTween.To(() => transform.localScale, x => transform.localScale = x, _defaultScale, _currentAnimationDuration).SetAs(_tweenParams); } if (HasColorAnimation) { for (byte i = 0; i < _defaultColor.Length; i++) { AnimateColors(i, _defaultColor[i], _currentAnimationDuration, _tweenParams); } } if (HasHighlightAnimation) { _tweenHighlight = DOTween.To(() => HighlightSprite.alpha, x => HighlightSprite.alpha = x, 0f, _currentAnimationDuration).SetAs(_tweenParams); } if (_hasUpSound) { MasterAudio.PlaySoundAndForget(_upSoundName); } } } _callbackRegistered = false; }
protected virtual void OnClick() { if (!_started) { Start(); } if (!isActivated) { if (string.IsNullOrEmpty(_deactivatedWarningMessageOverride)) { if (!string.IsNullOrEmpty(DefaultDeactivatedWarningMessage)) { WarningHandler.Instance.Warning(DefaultDeactivatedWarningMessage); if (_hasClickSound) { MasterAudio.PlaySoundAndForget(_clickSoundName); } } } else { WarningHandler.Instance.Warning(_deactivatedWarningMessageOverride); if (_hasClickSound) { MasterAudio.PlaySoundAndForget(_clickSoundName); } } } if (!isActivated) { return; } if (LongPress) { return; } if (SupportDoubleClick) { if (_tooFastClick) { StopCoroutine("RunDoubleClickWindow"); _tooFastClick = false; _alreadySentMessage = false; OnDoubleClickInternal(); return; } else { StartCoroutine("RunDoubleClickWindow"); } } if (Toggle) { if (_isToggled) { OnToggleOff(); return; } _isToggled = true; } StopTween(); _callbackRegistered = false; _currentAnimationDuration = AnimationDuration; if (HasScaleAnimation) { _tweenScale = DOTween.To(() => transform.localScale, x => transform.localScale = x, _pressedScale, _currentAnimationDuration).SetAs(_callbackRegistered ? _tweenParams : _tweenParamsCallback); if (!Toggle && !_callbackRegistered) { _callbackRegistered = true; } } if (HasColorAnimation) { for (byte i = 0; i < _defaultColor.Length; i++) { AnimateColors(i, _pressedColor[i], _currentAnimationDuration, _callbackRegistered ? _tweenParams : _tweenParamsCallback); if (!Toggle && !_callbackRegistered) { _callbackRegistered = true; } } } if (HasHighlightAnimation) { _tweenHighlight = DOTween.To(() => HighlightSprite.alpha, x => HighlightSprite.alpha = x, 1f, _currentAnimationDuration).SetAs(_callbackRegistered ? _tweenParams : _tweenParamsCallback); if (!Toggle && !_callbackRegistered) { _callbackRegistered = true; } } if (_hasClickSound) { MasterAudio.PlaySoundAndForget(_clickSoundName); } if ((UICamera.currentTouchID < 0 && UICamera.currentTouchID == -1) || UICamera.currentTouchID >= 0) { EventDelegate.Execute(onClick); } else if (UICamera.currentTouchID == -2) { EventDelegate.Execute(onLeftClick); } _callbackRegistered = false; }
public Sequence Play(int index, float speed, Action onComplete) { if (index < 0 || index >= Keyframes.Count) { return(null); } tweenSeq = DOTween.Sequence(); if (index == 0) { SetKeyframe(0); return(tweenSeq); } SetKeyframe(index - 1); List <SplineNode> targetNodes = Keyframes[index].nodes; if (targetNodes.Count > spline.nodes.Count) { Debug.LogWarningFormat("Spline nodes' count is less than keyframe_{0} nodes' count, so extra nodes will be created.", index); SplineNode lastNode = spline.nodes[spline.nodes.Count - 1]; for (int i = spline.nodes.Count; i < targetNodes.Count; i++) { spline.AddNode(new SplineNode(lastNode.position, lastNode.direction)); } } else if (targetNodes.Count < spline.nodes.Count) { Debug.LogWarningFormat("Spline nodes' count is more than keyframe_{0} nodes' count, so extra nodes will be deleted.", index); for (int i = targetNodes.Count; i < spline.nodes.Count; i++) { spline.RemoveNode(spline.nodes[i]); } } for (int i = 0; i < targetNodes.Count; i++) { SplineNode node = spline.nodes[i]; SplineNode targetNode = targetNodes[i]; Tweener posTweener = DOTween.To(() => node.position, x => node.SetPosition(x), targetNode.position, speed); if (i == 0) { tweenSeq.Append(posTweener); } else { tweenSeq.Join(posTweener); } Tweener dirTweener = DOTween.To(() => node.direction, x => node.SetDirection(x), targetNode.direction, speed); tweenSeq.Join(dirTweener); } tweenSeq.OnComplete(() => { tweenSeq = null; if (onComplete != null) { onComplete(); } }); CurIndex = index; return(tweenSeq); }
public static TweenerCore <float, float, FloatOptions> DOFadeTo(this CanvasGroup This, float target, float duration) { return(DOTween.To(() => This.alpha, value => This.alpha = value, target, duration).SetTarget(This)); }
Tween UpdateFillMiddle(float endValue) { float beginValue = fillMiddle.fillAmount; return(DOTween.To(() => beginValue, x => beginValue = x, endValue, 0.5f)); }
public void OnEndDrag(PointerEventData eventData) { float offSetX = 0; endMousePositionX = Input.mousePosition.x; offSetX = (beginMousePostionX - endMousePositionX) * 2; //Debug.Log("offSetX:" + offSetX); //Debug.Log("firstItemLength:" + firstItemLength); if (Mathf.Abs(offSetX) > firstItemLength) //执行滑动动作的前提是要大于第一个需要滑动的距离 { if (offSetX > 0) //右滑 { if (currentIndex >= totalItemNum) { return; } int moveCount = (int)((offSetX - firstItemLength) / oneItemLength) + 1;//当次可以移动的格子数目 currentIndex += moveCount; if (currentIndex >= totalItemNum) { currentIndex = totalItemNum; } //当次需要移动的比例:上一次已经存在的单元格位置 //的比例加上这一次需要去移动的比例 lastProportion += oneItemProportion * moveCount; if (lastProportion >= upperLimit) { lastProportion = 1; } } else //左滑 { if (currentIndex <= 1) { return; } int moveCount = (int)((offSetX + firstItemLength) / oneItemLength) - 1;//当次可以移动的格子数目 currentIndex += moveCount; if (currentIndex <= 1) { currentIndex = 1; } //当次需要移动的比例:上一次已经存在的单元格位置 //的比例加上这一次需要去移动的比例 lastProportion += oneItemProportion * moveCount; if (lastProportion <= lowerLimit) { lastProportion = 0; } } if (pageText != null) { pageText.text = currentIndex.ToString() + "/" + totalItemNum; } } DOTween.To(() => scrollRect.horizontalNormalizedPosition, lerpValue => scrollRect.horizontalNormalizedPosition = lerpValue, lastProportion, 0.5f).SetEase(Ease.OutQuint); GameManager.Instance.audioSourceManager.PlayPagingAudioClip(); }
public void NotSphereScene() { DOTween.To(() => MonocromeBGAlpha.alpha, x => MonocromeBGAlpha.alpha = x, 1, SceneFadeingSpeed).SetEase(Ease.InQuad); StartCoroutine(FadeInNotSphereScene()); }
private void GrowEffect() { DOTween.To(() => flowerLighting.intensity, x => flowerLighting.intensity = x, 18f, 2f).OnComplete(() => DegrowEffect());; }
void ShowImg1() { clk.Play(); DOTween.To(() => value, x => value = x, 1, 1.5f); Textshow.DOText(textshow[0], 4f).OnComplete(() => ban.gameObject.SetActive(false)); }
private void DegrowEffect() { DOTween.To(() => flowerLighting.intensity, x => flowerLighting.intensity = x, 0f, 1f); }
public static Tweener DOTextLong(this Text text, long initialValue, long finalValue, float duration, Func <long, string> convertor) { return(DOTween.To(() => initialValue, it => text.text = convertor(it), finalValue, duration)); }
//开启光照 public void EnableLight() { DOTween.To(() => lightScale, x => lightScale = x, 1.0f, 0.3f); isLighting = true; timeVal = duration; }
//check Obstacle void CheckObstacle() { if (CoreEntry.gCameraMgr.MainCamera == null || m_target == null) { return; } Ray ray = new Ray(m_target.position, -CoreEntry.gCameraMgr.MainCamera.transform.forward); RaycastHit[] hit; hit = Physics.RaycastAll(ray, 1000.0f, _nLayerMask); // 如果碰撞信息数量大于0条 if (hit.Length > 0) { for (int i = 0; i < hit.Length; i++) { _tempRenderer = hit[i].collider.gameObject.GetComponent <Renderer>(); if (rendererDict.ContainsKey(_tempRenderer)) { return; } rendererDict[_tempRenderer] = _tempRenderer.material.shader.name; //更改shader ChangeMaterial(_tempRenderer); if (_ObstacleCollider.Contains(_tempRenderer)) { return; } _ObstacleCollider.Add(_tempRenderer); float fadeIn = 1; Tween t = DOTween.To(() => fadeIn, x => fadeIn = x, 0f, 1); t.OnUpdate(() => SetMaterialsAlpha(_tempRenderer, fadeIn)); } }// 恢复障碍物透明度为1 else { if (_ObstacleCollider.Count > 0 && _ObstacleCollider != null) { for (int i = 0; i < _ObstacleCollider.Count; i++) { float fadeOut = 0; _tempRenderer = _ObstacleCollider[i]; Tween t = DOTween.To(() => fadeOut, x => fadeOut = x, 1f, 1); t.OnUpdate(() => SetMaterialsAlpha(_tempRenderer, fadeOut)); string shaderName = rendererDict[_tempRenderer]; t.OnComplete(() => { bool stillNeedFade = rendererDict.ContainsKey(_tempRenderer); if (!stillNeedFade) { ResetMaterial(_tempRenderer, shaderName); } }); } _ObstacleCollider.Clear(); rendererDict.Clear(); } } }
//关闭光照 public void DisableLight() { DOTween.To(() => lightScale, x => lightScale = x, 0.0f, 0.3f); isLighting = false; timeVal = 0; }
public static Tween MoveAnchored(this RectTransform rectTransform, Vector3 fromPosition, Vector3 toPosition, float time) { return(DOTween.To(() => rectTransform.anchoredPosition, (Vector3 pos) => rectTransform.anchoredPosition = pos, toPosition, time). OnStart(() => rectTransform.anchoredPosition = fromPosition)); }
public void TwoVotesTween() { TwoVotesMoveTween = TwoVotes.transform.GetComponent <RectTransform>().DOMoveY(-5, 0.5f); TwoVotesAppearTween = DOTween.To(() => TwoVotesGroup.alpha, x => TwoVotesGroup.alpha = x, 1, 0.5f); }
///Active this UI public virtual void Active() { this.transform.SetAsLastSibling(); this.gameObject.SetActive(true); isActived = true; GameObject tempObj = null; if (m_ContentTrans != null) { tempObj = m_ContentTrans.gameObject; } else { tempObj = this.gameObject; } if (alphaBackground == UIAlphaBackground.DoAlpha) { if (bgImg != null) { if (tweenShowColor != null) { tweenShowColor.Kill(); } float p2 = 0; tweenShowColor = DOTween.To(() => p2, x => p2 = x, 1, 0.28f); tweenShowColor.SetEase(Ease.Linear); tweenShowColor.OnUpdate(() => { Color c = bgImg.color; c.a = p2; bgImg.color = c; }); } } if (this.mode == UIMode.DoTween && tempObj != null) { if (tweenShowScale != null) { tweenShowScale.Kill(); } if (tweenShowScale1 != null) { tweenShowScale1.Kill(); } // DOTween.To (); Vector3 p2 = Vector3.zero; tweenShowScale = DOTween.To(() => p2, x => p2 = x, new Vector3(1.15f, 1.15f, 1), 0.12f); tweenShowScale.SetEase(Ease.InOutSine); tweenShowScale.OnUpdate(() => { //Debug.Log(p2); tempObj.transform.localScale = p2; }); tweenShowScale.OnComplete(() => { tweenShowScale1 = DOTween.To(() => p2, x => p2 = x, Vector3.one, 0.16f); tweenShowScale1.SetEase(Ease.InOutSine); tweenShowScale1.OnUpdate(() => { //Debug.Log(p2); tempObj.transform.localScale = p2; }); }); } //if (uiCurrency != null) //{ // uiCurrency.Active(); //} }
/// <summary> /// 关杯子并显示 /// </summary> /// <param name="Cup"></param> private void CloseCupAnim(Image Cup) { DOTween.To(() => Cup.transform.localPosition, pos => Cup.transform.localPosition = pos, new Vector3(55, 0, 0), 0.6f).SetEase(Ease.Linear); DOTween.To(() => Cup.color, a => Cup.color = a, new Color(255, 255, 255, 255), 0.7f).SetEase(Ease.InQuint); }