public void Lerp(LerpData ld, bool canTeleport) { if (Application.isPlaying && position != null) { position.Lerp(ld, canTeleport); transparency.Lerp(ld, false); toMainMenuGraphics.TrySetAlpha_DisableIfZero(1 - transparency.CurrentValue); mainMenuUIGraphics.TrySetAlpha_DisableIfZero(transparency.CurrentValue); } }
public override void Portion(LerpData ld) { if (!isFadingAway) { gotAnotherText = targetText != null; if (gotAnotherText || dirty) { textFade.Portion(ld, gotAnotherText ? 1 : 0.5f); textColor.Portion(ld, activeTexts.textColor); } } }
public void Portion(LerpData ld) { if (position == null) { position = new LinkedLerp.RectangleTransformAnchoredPositionValue(rectTranform, 800); } if (showCreateButtons && !gameObject.activeSelf) { gameObject.SetActive(true); } position.TargetValue = Destination; position.Portion(ld); }
public override bool Update(RoundedGraphic target) { _roundedCorners.targetValue = target._mouseOver ? valueWhenOver : valueWhenOff; var ld = new LerpData(); _roundedCorners.Portion(ld); _roundedCorners.Lerp(ld); if (_roundedCorners.CurrentValue != target.GetCorner(0)) { target.SetCorners(_roundedCorners.CurrentValue); return(true); } return(false); }
private void Update() { LerpData lr = new LerpData(); color0.Portion(lr, GetPreviewColor(1)); // = ); //color1.Portion(lr, GetColor(1)); color2.Portion(lr, GetPreviewColor(2)); outline.Portion(lr, GetPreviewColor(0)); color0.Lerp(lr); //color1.Lerp(lr); color2.Lerp(lr); outline.Lerp(lr); shotsDelay -= Time.deltaTime; if ((shotsToDo > 0) && (shotsDelay < 0)) { audioSource.PlayOneShot(scoreSound); shotsDelay = 0.02f; shotsToDo--; } if (placing) { TryPlace(); } #if !UNITY_ANDROID updatePointedSector(); #endif for (int i = currentPlacingBlock; i < blocksToPlace; i++) { BlockScript b = givenBlocks[i]; float scale = b.transform.localScale.x; scale = Mathf.Lerp(scale, (i == currentPlacingBlock) ? 1 : 0.5f, Time.deltaTime * 10); b.transform.localScale = Vector3.one * scale; } }
public override void Lerp(LerpData ld, bool canSkipLerp) { if (gameObject.activeSelf) { addButtonCourner.Lerp(ld); NodesPool.Lerp(ld); slidingButtons.Lerp(ld); addButton.SetCorner(1, addButtonCourner.CurrentValue); if (!isFading) { var col = MainCamera.backgroundColor; } else if (ld.Portion() == 1) { gameObject.SetActive(false); } } }
static Interpolator Start(LerpData data, string lerpName, bool reversed) { GameObject newContainer = new GameObject("Interpolator-" + lerpName); Interpolator interpolator = newContainer.AddComponent <Interpolator>(); interpolator.isFloat = data.IsFloat; interpolator.startFloat = data.StartFloat; interpolator.endFloat = data.EndFloat; interpolator.startVector = data.StartVector; interpolator.endVector = data.EndVector; interpolator.duration = data.duration; interpolator.onTick = data.onTick; interpolator.onTickVector = data.onTickVector; interpolator.onFinish = data.onFinish; if (data.curve == null || data.curve.keys.Length <= 1) { AnimationCurve newCurve = new AnimationCurve(); Keyframe startKey = new Keyframe(0, 0); newCurve.AddKey(startKey); Keyframe endKey = new Keyframe(1, 1); newCurve.AddKey(endKey); interpolator.curve = newCurve; } else { interpolator.curve = data.curve; } if (reversed) { interpolator.timer = 1.0f; interpolator.reversed = true; } return(interpolator); }
public void Lerp(LerpData ld, bool canSkipLerp = false) { #region Drag UpdateCoverImage(); if (this == _dragging) { if (isFading || !Shortcuts.editingNodes || !Input.GetMouseButton(0)) { _dragging = null; } else { Vector3 pos; if (UpPlane.MouseToPlane(out pos, MainCamera)) { transform.localPosition = pos + _dragOffset; ActiveConfig.targetLocalPosition = transform.localPosition; } } SetDirty(); } #endregion #region Lerp Visual if (includedInLerp) { var ac = ActiveConfig; var needShaderUpdate = false; if (!lerpsFinished && (this != _dragging)) { needShaderUpdate = true; _shBlur = Mathf.Lerp(_shBlur, Mathf.Clamp01((transform.localPosition - _localPos.targetValue).magnitude * 5), Time.deltaTime * 10); fadePortion = Mathf.Lerp(fadePortion, isFading ? 0 : 1, ld.MinPortion); var scale = _localScale.CurrentValue; if (scale.x > 0) { _shSquare.x = scale.x > scale.y ? ((scale.x - scale.y) / scale.x) : 0; } else { _shSquare.x = 0; } if (scale.y > 0) { _shSquare.y = scale.y > scale.x ? ((scale.y - scale.x) / scale.y) : 0; } else { _shSquare.y = 0; } var textSize = new Vector2(17 + scale.x * 3, 5f + Mathf.Max(0, (scale.y - 1f) * 3f)); textA.rectTransform.sizeDelta = textSize; textB.rectTransform.sizeDelta = textSize; } if (!lerpsFinished && (this != _dragging) && ld.MinPortion == 1 && LerpPosition) { lerpsFinished = true; } if (newText != null || _activeTextAlpha < 1) { lerpsFinished = false; _activeTextAlpha = newText == null ? Mathf.Lerp(_activeTextAlpha, 1, ld.Portion()) : LerpUtils.LerpBySpeed(_activeTextAlpha, 1, 4); if (_activeTextAlpha == 1 && newText != null) { _activeTextIsA = !_activeTextIsA; ActiveText.text = newText; gameObject.name = newText; _activeTextAlpha = 0; newText = null; } needShaderUpdate = true; } bool skipLerpPossible = (_canJumpToPosition && fadePortion < 0.1f && !isFading); bgColor = Color.Lerp(bgColor, ac.targetColor, ld.Portion(skipLerpPossible)); _textColor.Lerp(ld, skipLerpPossible); if (LerpPosition) { _localPos.Lerp(ld); } _localScale.Lerp(ld, skipLerpPossible); _shadeCorners.Lerp(ld, skipLerpPossible); _shadeSelected.Lerp(ld, skipLerpPossible); _textureFadeIn.Lerp(ld, skipLerpPossible); _texTransition.Lerp(ld, skipLerpPossible); if (needShaderUpdate) { OnShaderParametersChanged(); } if (fadePortion == 0 && isFading && Application.isPlaying) { BoxButtons.inst.Deactivate(this); } } #endregion #region Link bool gotLinkTarget = false; if (!_latestParent) { if (source != null && source.parentNode != null && source.parentNode == CurrentNode) { _latestParent = source.parentNode.visualRepresentation as NodeCircleController; } } if (_latestParent) { if (_latestParent.gameObject.activeSelf) { if (!_latestParent.isFading && (_latestParent.source != null) && (source != null) && (_latestParent.source == source.parentNode)) { linkRenderer.startColor = linkRenderer.startColor.LerpBySpeed(bgColor, 5); linkRenderer.endColor = linkRenderer.endColor.LerpBySpeed(_latestParent.bgColor, 5); if (!linkRenderer.gameObject.activeSelf) { linkRenderer.gameObject.SetActive(true); } gotLinkTarget = true; } linkRenderer.SetPosition(0, transform.position + Vector3.down * 0.1f); linkRenderer.SetPosition(1, _latestParent.transform.position + Vector3.down * 0.1f); } } if (!gotLinkTarget) { linkRenderer.LerpAlpha_DisableIfZero(0, 1); } #endregion if (LevelArea) { LevelArea.Lerp(ld, false); } if (_mouseDown && ((Time.time - _overDownTime) > 0.2f)) { _mouseDown = false; lerpsFinished = false; audioSource.Stop(); Debug.Log("Stopping on leave"); audioSource.PlayOneShot(Shortcuts.Assets.onMouseLeaveSound); } }
private IEnumerator LerpPositionTo(LerpData data){ float ivDuration = 1f / data.duration; float t = 0, v = 0; Vector3 start = go.transform.position; while (t<data.duration) { t+=Time.deltaTime; v = Mathf.Clamp(t*ivDuration, 0, 1); LerpPositionStep(v); go.transform.position = Vector3.Lerp(start, data.vectorValue, v); yield return null; } LerpPositionComplete (); }
private IEnumerator LerpLocalRotationTo(LerpData data){ float ivDuration = 1f / data.duration; float t = 0, v = 0; Quaternion start = go.transform.localRotation; while (t<data.duration) { t+=Time.deltaTime; v = Mathf.Clamp(t*ivDuration, 0, 1); LerpLocalRotationStep(v); go.transform.localRotation = Quaternion.Lerp(start, Quaternion.Euler(data.vectorValue), v); yield return null; } LerpLocalRotationComplete (); }
public abstract void Portion(LerpData ld);
public abstract void Lerp(LerpData ld, bool canSkipLerp);
public void Portion(LerpData ld) { bgColUp.Portion(ld); bgColCnter.Portion(ld); bgColDown.Portion(ld); }
public void Lerp(LerpData ld, bool canSkipLerp) { bgColUp.Lerp(ld); bgColCnter.Lerp(ld); bgColDown.Lerp(ld); }
private IEnumerator LerpCustomTo(LerpData data){ float ivDuration = 1f / data.duration; float t = 0, v = 0; while (t<data.duration) { t+=Time.deltaTime; v = Mathf.Clamp(t*ivDuration, 0, 1); LerpCustomStep(v); yield return null; } LerpCustomComplete (); }
public void Portion(LerpData ld) { lerpsFinished &= !_mouseDown; includedInLerp = (gameObject.activeSelf && !lerpsFinished && this != _dragging); if (!includedInLerp) { return; } var ac = ActiveConfig; if (LerpPosition) { if (!isFading || !_fadingRelation) { _localPos.targetValue = ac.targetLocalPosition; } else if (!_fadingIntoParent) { _localPos.targetValue = _fadingRelation.transform.localPosition + (transform.localPosition - _fadingRelation.transform.localPosition) .normalized * 50; } else { _localPos.targetValue = _fadingRelation.transform.localPosition; } _localPos.Portion(ld); } _localScale.Portion(ld, isFading ? Vector3.one : ac.targetSize); _textColor.Portion(ld, ac.targetTextColor); if (16f.SpeedToMinPortion(ac.targetColor.DistanceRgb(bgColor), ld)) { dominantParameter = "Box Bttn BG Color"; } if (4f.SpeedToMinPortion(fadePortion - (isFading ? 0f : 1f), ld)) { dominantParameter = "Box Button Fade"; } if (8f.SpeedToMinPortion(1 - _activeTextAlpha, ld)) { dominantParameter = "Box Button Text Alpha"; } _textureFadeIn.Portion(ld, _coverImage ? 1 : 0); _shadeCorners.Portion(ld, (this == _dragging) ? 0 : (_mouseDown ? 0.1f : ((source == Shortcuts.CurrentNode) ? 0.4f : 0.9f))); _shadeSelected.Portion(ld, (this == BoxButtons.inst.selectedNode ? 1f : 0f)); _texTransition.Portion(ld); if (LevelArea) { LevelArea.Portion(ld); } }
public void Portion(LerpData ld) { transparency.Portion(ld, isFadingOut ? 0 : 1); upperEdge.Portion(ld, isFirst ? 0 : 1); loverEdge.Portion(ld, isLast ? 0 : 1); }