public IEnumerator FadeOut(CanvasGroup cGroup) { if (Metrics.EqualFloats(cGroup.alpha, 0, 0.01)) { yield return(null); } StopCoroutine(FadeIn(cGroup)); if (!MovingSlot.IsEmpty) { Inventory.Instance.DropItems(MovingSlot.Items.ToList(), PlayerManager.Instance.player.GetComponent <Player>().transform); MovingSlot.ClearSlot(); Destroy(GameObject.Find("Hover")); } var startBlurAlpha = blur.material.GetFloat(Size); var startAlpha = cGroup.alpha; var rate = 1.0f / fadeTime; var progress = 0.0f; while (progress < 1.0) { blur.material.SetFloat(Size, Mathf.Lerp(startBlurAlpha, 0, progress)); cGroup.alpha = Mathf.Lerp(startAlpha, 0, progress); progress += rate * Time.deltaTime; yield return(null); } cGroup.blocksRaycasts = false; cGroup.alpha = 0; blur.material.SetFloat(Size, 0); }
private void Update() { if (HoverObject != null) { RectTransformUtility.ScreenPointToLocalPointInRectangle( canvas.transform as RectTransform, Input.mousePosition, canvas.worldCamera, out var position); position.Set(position.x, position.y - HoverYOffset); HoverObject.transform.position = canvas.transform.TransformPoint(position); } if (toolTipObject.activeSelf) { var xPos = Input.mousePosition.x; var yPos = Input.mousePosition.y; //TODO modify it only on resolution change _widthRatio = Screen.width / canvasScaler.referenceResolution.x; _heightRatio = Screen.height / canvasScaler.referenceResolution.y; var localScale = inventoryTransform.localScale; toolTipObject.transform.position = new Vector2( Mathf.Clamp(xPos, 14 * _widthRatio, Screen.width - (visualTextRect.rect.width + 22) * _widthRatio * localScale.x), Mathf.Clamp(yPos, (visualTextRect.rect.height + 22) * _heightRatio * localScale.y, Screen.height - 14 * _heightRatio * localScale.y)); } if (Input.GetMouseButtonUp(0) && !eventSystem.IsPointerOverGameObject(-1) && !MovingSlot.IsEmpty) { Inventory.Instance.DropItems(MovingSlot.Items.ToList(), _playerRef.transform); MovingSlot.ClearSlot(); Destroy(GameObject.Find("Hover")); } if (!MovingSlot.IsEmpty) { toolTipObject.SetActive(false); } }