void Update() { if (targetText.text.Length == 0) { rootCanvasGroup.alpha = 0f; } else { rootCanvasGroup.alpha = 1f; } var ray = Camera.main.ScreenPointToRay(Input.mousePosition); var hit = default(RaycastHit); if (Physics.Raycast(ray, out hit, DescribeTextObjectLayerMask)) { var describeTextObject = hit.transform.GetComponent <DescribeTextObject>(); if (!describeTextObject.needHit || Input.GetMouseButtonDown(0)) { if (mLastDescribeTextObject != describeTextObject) { var content = describeTextObject.content; PopupText(content); mLastDescribeTextObject = describeTextObject; } } } }
IEnumerator PopupTextCoroutine(string content) { var sb = new StringBuilder(); yield return(GradientText(content, str => targetText.text = str, sb, 0.8f)); yield return(new WaitForSeconds(2f)); targetText.text = ""; mLastDescribeTextObject = null; }