public void Hide() { if (coroutine != null) { toaster.StopCoroutine(coroutine); } coroutine = toaster.StartCoroutine(Toaster.CoAnimateToast(toast, 0)); }
public void Destroy(float time = 0) { if (coroutine != null) { toaster.StopCoroutine(coroutine); } toaster.StartCoroutine(Toaster.CoAnimateToast(toast, 0, GetDestroyCallback(toast))); coroutine = null; toast = null; }
public void Show(string text = null) { if (text as object != null) { toast.GetComponentInChildren <Text>().text = text; } if (coroutine != null) { toaster.StopCoroutine(coroutine); } coroutine = toaster.StartCoroutine(Toaster.CoAnimateToast(toast, 1)); }
void OnDestroy() { if (singleton == this) { singleton = null; for (int i = 0; i < (int)ToastGroup.Count; i++) { if (toastRoots[i]) { Destroy(toastRoots[i].gameObject); } } //if (leftTransform) Destroy(leftTransform.gameObject); //if (rightTransform) Destroy(rightTransform.gameObject); //if (frontalTransform) Destroy(frontalTransform.gameObject); } }
void Awake() { if (singleton) { DestroyImmediate(this, false); return; } singleton = this; toastRoots[(int)ToastGroup.LeftHand] = new GameObject("VRToaster_LeftText", WrapperComponentList).GetComponent <RectTransform>(); toastRoots[(int)ToastGroup.RightHand] = new GameObject("VRToaster_RightText", WrapperComponentList).GetComponent <RectTransform>(); toastRoots[(int)ToastGroup.Frontal] = new GameObject("VRToaster_FrontText", WrapperComponentList).GetComponent <RectTransform>(); InitWrapper(toastRoots[(int)ToastGroup.LeftHand], handToastWidth, handToastDensity); InitWrapper(toastRoots[(int)ToastGroup.RightHand], handToastWidth, handToastDensity); InitWrapper(toastRoots[(int)ToastGroup.Frontal], frontalToastWidth, frontalToastDensity); handTextPadding = Mathf.RoundToInt(handToastWidth * handToastDensity * toastPadding); frontalTextPadding = Mathf.RoundToInt(frontalToastWidth * frontalToastDensity * toastPadding); }
public void Replace(string text) { if (coroutine != null) { toaster.StopCoroutine(coroutine); } coroutine = null; toaster.StartCoroutine(Toaster.CoAnimateToast(toast, 0, GetDestroyCallback(toast))); var clone = Object.Instantiate(toast, toast.parent, true); var rect = clone.GetComponent <RectTransform>(); rect.SetSiblingIndex(toast.GetSiblingIndex() + 1); rect.localScale = new Vector3(1, 0, 1); clone.GetComponent <CanvasGroup>().alpha = 0; toast = clone; Show(text); }
public Toast(RectTransform w, Toaster t) { toast = w; toaster = t; }