// Update is called once per frame void Update() { if (IsMouseOver && HoverPhase < 1f) { HoverPhase = Mathf.Min(1f, HoverPhase + Time.deltaTime * 3f); } if (!IsMouseOver && HoverPhase > 0f) { HoverPhase = Mathf.Max(0f, HoverPhase - Time.deltaTime * 3f); } var scaleAdd = EasingFunction.EaseInOutBack(0f, 0.1f, HoverPhase); MyRectTransform.localScale = new Vector3(1f + scaleAdd, 1f + scaleAdd, 1f); StripsPhase += Time.deltaTime * 2f; if (StripsPhase > 1f) { StripsPhase -= 1f; } Strips.anchoredPosition = new Vector2(-60 + 60 * StripsPhase, 0f); if (IsMouseOver) { Background.color = HoverColor; // new Color(90f / 255f, 240f / 255f, 212f / 255f); Hover.SetActive(true); } else { Background.color = BaseColor; // new Color(31f / 255f, 217f / 255f, 181f / 255f); Hover.SetActive(false); } }
private IEnumerator LifeTimeCoroutine() { while (_elapsedTime <= _durationTime) { _elapsedTime += Time.deltaTime; float factor = Mathf.Clamp01(_elapsedTime / (_appearTime)); transform.localScale = Vector3.Lerp(Vector3.zero, Vector3.one, EasingFunction.EaseInOutBack(0.0f, 1.0f, factor)); if (_spriteRenderer != null) { var sprite_color = _spriteRenderer.color; sprite_color.a = Mathf.Clamp01(_durationTime - _elapsedTime); _spriteRenderer.color = sprite_color; } yield return(null); } Destroy(gameObject); }
// Update is called once per frame void Update() { Phase += Time.deltaTime * 4f; while (Phase > 2f) { Phase -= 2f; } var p = 0f; if (Phase < 1f) { p = EasingFunction.EaseInOutBack(0f, 1f, Phase); } else { p = EasingFunction.EaseInOutBack(1f, 0f, Phase - 1f); } var scale = (p * 0.2f) + 0.8f; var pos = p * 5f; MyTransform.anchoredPosition = new Vector2(MyTransform.anchoredPosition.x, StartY + pos); MyTransform.localScale = new Vector3(1f, scale, 1f); }
// Update is called once per frame void Update() { if (HoverAudioPause > 0f) { HoverAudioPause -= Time.deltaTime; } SelectionPhase += Time.deltaTime; if (SelectionPhase > 1f) { SelectionPhase -= 1f; } SelectionImageTransform.anchoredPosition = new Vector2(-20f + 20f * SelectionPhase, 0f); if (IsSelected || IsHighlighted) { HoverPhase = 1f; } else { if (IsMouseOver && HoverPhase < 1f) { HoverPhase = Mathf.Min(1f, HoverPhase + Time.deltaTime * 5f); } if (!IsMouseOver && HoverPhase > 0f) { HoverPhase = Mathf.Max(0f, HoverPhase - Time.deltaTime * 3f); } } var scaleAdd = EasingFunction.EaseInOutBack(0f, 0.2f, HoverPhase); MyTransform.localScale = new Vector3(1f + scaleAdd, 1f + scaleAdd, 1f); ImageTransform.localScale = new Vector3(1f - scaleAdd / 2f, 1f - scaleAdd / 2f, 1f); SelectionBorderTransform.localScale = new Vector3(1f - scaleAdd / 2f, 1f - scaleAdd / 2f, 1f); TransparencyTransform.localScale = new Vector3(1f - scaleAdd / 2f, 1f - scaleAdd / 2f, 1f); TransparencyBackgroundTransform.localScale = new Vector3(1f - scaleAdd / 2f, 1f - scaleAdd / 2f, 1f); BorderImage.color = new Color(BorderImage.color.r, BorderImage.color.g, BorderImage.color.b, HoverPhase); if (IsMouseOver) { var pos = Controller.Instance.RectTransform.InverseTransformPoint(MyTransform.position); pos.x += Controller.Instance.RectTransform.rect.width / 2f; pos.y -= Controller.Instance.RectTransform.rect.height / 2f - MyTransform.rect.height / 1.5f; Controller.Instance.MoveTooltip(pos); } /* * StripsPhase += Time.deltaTime * 2f; * if (StripsPhase > 1f) * StripsPhase -= 1f; * Strips.anchoredPosition = new Vector2(-60 + 60 * StripsPhase, 0f); * if (IsMouseOver) * { * Background.color = new Color(90f / 255f, 240f / 255f, 212f / 255f); * Hover.SetActive(true); * } * else * { * Background.color = new Color(31f / 255f, 217f / 255f, 181f / 255f); * Hover.SetActive(false); * }*/ }