예제 #1
0
 void OnAlertViewWillDisappear(UIAlertViewControllerBase sender)
 {
     if (showStack.Count > 0)
     {
         showStack.Pop();
     }
 }
예제 #2
0
    void OnAlertViewDidAppear(UIAlertViewControllerBase sender)
    {
        //push current params
        showStack.Push(currentShowAlertParams);

        if (showQueue.Count > 0)
        {
            ShowAlertGenericParams genericParams_ = showQueue.Dequeue();

            System.Type genericType_   = genericParams_.genericType;
            MethodInfo  genericMethod_ = GetType().GetMethod("ShowAlertGeneric").MakeGenericMethod(genericType_);
            genericMethod_.Invoke(this, genericParams_.invokeParams);
        }
    }
예제 #3
0
    void OnAlertViewDidDisappear(UIAlertViewControllerBase sender)
    {
        if (showStack.Count > 0)
        {
            ShowAlertGenericParams genericParams_ = showStack.Pop();

            System.Type genericType_   = genericParams_.genericType;
            MethodInfo  genericMethod_ = GetType().GetMethod("ShowAlertGeneric").MakeGenericMethod(genericType_);
            genericMethod_.Invoke(this, genericParams_.invokeParams);
        }
        else
        {
            Hide_();
        }
    }
예제 #4
0
    public void ShowAlertGeneric <T> (object[] alertPresentParams_, GameObject alertCallbackTarget_, string alertCallbackMethod_, string alertPrefabPath_) where T : UIAlertViewControllerBase
    {
        System.Type            alertType_       = typeof(T);
        ShowAlertGenericParams showAlertParams_ = new ShowAlertGenericParams(alertPresentParams_, alertCallbackTarget_, alertCallbackMethod_, alertPrefabPath_, alertType_);

        if ((avController != null) ?avController.IsAppearAnimationPlaying :false)
        {
            showQueue.Enqueue(showAlertParams_);
            return;
        }

        bool specificAlertViewExists_ = (avController != null) ?avController.GetType().Equals(alertType_) :false;

        if (!specificAlertViewExists_)
        {
            if (avController == null)
            {
                FadeIn_();
                //create stack
                showStack = new System.Collections.Generic.Stack <ShowAlertGenericParams>();
                showQueue = new System.Collections.Generic.Queue <ShowAlertGenericParams>();
            }
            else
            {
                Destroy(avController.gameObject);
                avController = null;
            }

            GameObject prefab = Resources.Load(alertPrefabPath_) as GameObject;

            GameObject avClone = NGUITools.AddChild(Instance._uiPanel.gameObject, prefab);
            avController = avClone.GetComponent <UIAlertViewControllerBase>();

            avController.onAlertViewButton        = OnAlertViewButton;
            avController.onAlertViewDidAppear     = OnAlertViewDidAppear;
            avController.onAlertViewDidDisappear  = OnAlertViewDidDisappear;
            avController.onAlertViewWillDisappear = OnAlertViewWillDisappear;
        }

        currentShowAlertParams = showAlertParams_;

        avController.transform.localPosition = Vector3.zero + Vector3.back;
        MethodInfo specificAlertMethod_ = alertType_.GetMethod("Show", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

        specificAlertMethod_.Invoke(avController, alertPresentParams_);
    }
예제 #5
0
    protected void FadeOut_()
    {
        if (avController != null)
        {
            Destroy(avController.gameObject);
            avController = null;
            Resources.UnloadUnusedAssets();
        }

        TweenColor colorTweener = fadeTexture.GetComponentInChildren <TweenColor>();

        if (colorTweener == null)
        {
            colorTweener = fadeTexture.gameObject.AddComponent <TweenColor>();
        }

        colorTweener.from = new Color(0f, 0f, 0f, 0f);
        colorTweener.to   = fadeColor;

        colorTweener.duration = appearFadeDuration;
        colorTweener.Play(false);

        currentShowAlertParams = null;
    }