private void OnSceneGUI() { ToastAnimationSettings t = target as ToastAnimationSettings; RectTransform rt = t.gameObject.GetComponent <RectTransform>(); Vector3[] corners = new Vector3[4]; rt.GetWorldCorners(corners); Vector2 pivot = new Vector2(corners[0].x + (rt.rect.width * rt.pivot.x), corners[0].y + (rt.rect.height * rt.pivot.y)); for (int i = 0; i < corners.Length; ++i) { corners[i] += (Vector3)t.offset; // corners[i] = corners[i] + (Vector3)offsetProperty.vector2Value; } // Handles.BeginGUI(); { Handles.color = Color.grey; Handles.DrawLine(corners[0], corners[1]); Handles.DrawLine(corners[1], corners[2]); Handles.DrawLine(corners[2], corners[3]); Handles.DrawLine(corners[3], corners[0]); Handles.DrawLine(pivot, pivot + t.offset); Handles.DrawWireDisc(pivot + t.offset, Vector3.forward, 10f); Handles.color = Color.white; Handles.DrawDottedLine(corners[0], corners[1], 10f); Handles.DrawDottedLine(corners[1], corners[2], 10f); Handles.DrawDottedLine(corners[2], corners[3], 10f); Handles.DrawDottedLine(corners[3], corners[0], 10f); Handles.DrawDottedLine(pivot, pivot + t.offset, 10f); Handles.DrawWireDisc(pivot + t.offset, Vector3.forward, 9f); } // Handles.EndGUI(); }
private System.Collections.IEnumerator DisplayNextMessageRoutine() { MessageDisplayData message = queuedMessages[0]; MessageDisplay dialog = m_typeDialogMap[message.type]; ToastAnimationSettings anim = dialog.GetComponent <ToastAnimationSettings>(); RectTransform rectTransform = dialog.GetComponent <RectTransform>(); Vector2 origin = rectTransform.anchoredPosition; if (dialog != null) { dialog.content.text = message.content; dialog.gameObject.SetActive(true); if (anim != null) { float animTimer = 0f; while (animTimer < anim.duration) { rectTransform.anchoredPosition = Vector2.Lerp(origin + anim.offset, origin, animTimer / anim.duration); yield return(null); animTimer += Time.unscaledDeltaTime; } rectTransform.anchoredPosition = origin; } float displayTimer = 0f; m_cancelCurrentMessage = false; while (displayTimer < message.displayDuration && !m_cancelCurrentMessage) { yield return(null); displayTimer += Time.unscaledDeltaTime; } if (anim != null) { float animTimer = 0f; while (animTimer < anim.duration) { rectTransform.anchoredPosition = Vector2.Lerp(origin, origin + anim.offset, animTimer / anim.duration); yield return(null); animTimer += Time.unscaledDeltaTime; } rectTransform.anchoredPosition = origin; } dialog.gameObject.SetActive(false); } queuedMessages.Remove(message); m_displayRoutine = null; if (Application.isPlaying && this != null && this.isActiveAndEnabled && queuedMessages.Count > 0) { m_displayRoutine = StartCoroutine(DisplayNextMessageRoutine()); } }