示例#1
0
文件: Toast.cs 项目: m4ff/VRToaster
 public void Hide()
 {
     if (coroutine != null)
     {
         toaster.StopCoroutine(coroutine);
     }
     coroutine = toaster.StartCoroutine(Toaster.CoAnimateToast(toast, 0));
 }
示例#2
0
文件: Toast.cs 项目: m4ff/VRToaster
 public void Destroy(float time = 0)
 {
     if (coroutine != null)
     {
         toaster.StopCoroutine(coroutine);
     }
     toaster.StartCoroutine(Toaster.CoAnimateToast(toast, 0, GetDestroyCallback(toast)));
     coroutine = null;
     toast     = null;
 }
示例#3
0
文件: Toast.cs 项目: m4ff/VRToaster
        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));
        }
示例#4
0
文件: Toaster.cs 项目: m4ff/VRToaster
        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);
            }
        }
示例#5
0
文件: Toaster.cs 项目: m4ff/VRToaster
        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);
        }
示例#6
0
文件: Toast.cs 项目: m4ff/VRToaster
        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);
        }
示例#7
0
文件: Toast.cs 项目: m4ff/VRToaster
 public Toast(RectTransform w, Toaster t)
 {
     toast   = w;
     toaster = t;
 }