コード例 #1
0
    IEnumerator OpenTipAc(TipType tipType, string describe, float waitTime, UnityAction sureAction, UnityAction cancelAction)
    {
        Instance.gameObject.transform.SetAsLastSibling();
        Transform tf = GetTip(tipType);

        if (tf)
        {
            tf.Find("Describe").GetComponent <Text>().text = describe;
            if (tipType != TipType.SimpleTip)
            {
                UIUtils.RegisterButton("BtnSure", () => { ButtonCallBack(tf.gameObject, sureAction); }, tf);
                UIUtils.RegisterButton("BtnClose", () => { tf.gameObject.SetActive(false); }, tf);
                if (tipType == TipType.ChooseTip)
                {
                    UIUtils.RegisterButton("BtnCancel", () => { ButtonCallBack(tf.gameObject, cancelAction); }, tf);
                }
            }
            else
            {
                if (waitTime == 0)
                {
                    waitTime = 3;
                }
                UIUtils.RegisterButton("Background", () => { Destroy(tf.gameObject); }, tf);
            }
            tf.gameObject.SetActive(true);
            SetCanvasRarcaster();
            LoadingNode.CloseLoadingNode();
            Transform timerTf = tf.Find("Timer");
            if (waitTime != 0)
            {
                if (timerTf)
                {
                    Timer timer = timerTf.GetComponent <Timer>();
                    timer.allLength = waitTime;
                    timer.ResetTimer(true);
                }
                bool isSimpleTip = tipType.Equals(TipType.SimpleTip);
                yield return(new WaitForSecondsRealtime(waitTime));

                if (tf && tf.gameObject.activeSelf)
                {
                    if (isSimpleTip)
                    {
                        Destroy(tf.gameObject);
                    }
                    else
                    {
                        tf.gameObject.SetActive(false);
                    }
                    if (cancelAction != null)
                    {
                        cancelAction();
                    }
                }
            }
            else
            if (timerTf)
            {
                timerTf.gameObject.SetActive(false);
            }
        }
    }