Пример #1
0
        public void DoneFinished()
        {
            if (DoneCallback != null)
            {
                DoneCallback(this);
            }

            DialogGameObject.SetActive(false);

            if (_destroyOnClose)
            {
                Destroy(gameObject);
            }

            // decrease open count - not thread safe, but should be ok!
            DialogManager.Instance.Count--;
            IsShown = false;

            if (_swapToDialogInstance != null)
            {
                _swapToDialogInstance.Show(destroyOnClose: false);
                _swapToDialogInstance = null;
            }
        }
Пример #2
0
        public void Show(string title = null, string titleKey = null, string text   = null, string textKey = null,
                         string text2 = null, string text2Key = null, Sprite sprite = null,
                         System.Action <DialogInstance> doneCallback = null, bool destroyOnClose = true,
                         DialogButtonsType dialogButtons             = DialogButtonsType.Custom)
        {
            GameObject childGameObject;

            DialogButtons   = dialogButtons;
            DoneCallback    = doneCallback;
            _destroyOnClose = destroyOnClose;

            // increase open count - not thread safe, but should be ok!
            DialogManager.Instance.Count++;
            IsShown = true;

            // default result
            DialogResult = DialogResultType.Ok;

            if (titleKey != null)
            {
                title = LocaliseText.Get(titleKey);
            }
            if (title != null)
            {
                UIHelper.SetTextOnChildGameObject(gameObject, "ph_Title", title, true);
            }

            if (sprite != null)
            {
                UIHelper.SetSpriteOnChildGameObject(gameObject, "ph_Image", sprite, true);
            }
            else
            {
                childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Image", true);
                if (childGameObject != null)
                {
                    childGameObject.SetActive(false);
                }
            }

            if (textKey != null)
            {
                text = LocaliseText.Get(textKey);
            }
            if (text != null)
            {
                UIHelper.SetTextOnChildGameObject(gameObject, "ph_Text", text, true);
            }
            else
            {
                childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Text", true);
                if (childGameObject != null)
                {
                    childGameObject.SetActive(false);
                }
            }

            if (text2Key != null)
            {
                text2 = LocaliseText.Get(text2Key);
            }
            if (text2 != null)
            {
                UIHelper.SetTextOnChildGameObject(gameObject, "ph_Text2", text2, true);
            }
            else
            {
                childGameObject = GameObjectHelper.GetChildNamedGameObject(gameObject, "ph_Text2", true);
                if (childGameObject != null)
                {
                    childGameObject.SetActive(false);
                }
            }

            switch (DialogButtons)
            {
            case DialogButtonsType.Ok:
                GameObjectHelper.GetChildNamedGameObject(gameObject, "OkButton", true).SetActive(true);
                break;

            case DialogButtonsType.OkCancel:
                GameObjectHelper.GetChildNamedGameObject(gameObject, "OkButton", true).SetActive(true);
                GameObjectHelper.GetChildNamedGameObject(gameObject, "CancelButton", true).SetActive(true);
                break;

            case DialogButtonsType.Cancel:
                GameObjectHelper.GetChildNamedGameObject(gameObject, "CancelButton", true).SetActive(true);
                break;

            case DialogButtonsType.YesNo:
                GameObjectHelper.GetChildNamedGameObject(gameObject, "YesButton", true).SetActive(true);
                GameObjectHelper.GetChildNamedGameObject(gameObject, "NoButton", true).SetActive(true);
                break;
            }

            // show / transition in and when done call coroutine
            float transitionTime = 0;

            DialogGameObject.SetActive(true);
#if BEAUTIFUL_TRANSITIONS
            //if (TransitionHelper.ContainsTransition(gameObject))
            //{
            transitionTime = TransitionHelper.GetTransitionInTime(TransitionHelper.TransitionIn(gameObject));
            //}
#endif
            StartCoroutine(CoRoutines.DelayedCallback(transitionTime, ShowFinished));
        }