Ejemplo n.º 1
0
 public GIISimpleCommand(string name, FuncCallback0 fn = null, string closure = null)
 {
     _name      = name;
     _execution = fn;
     _closure   = closure;
     _closed    = false;
 }
 public static void StartCoroutineDelay(this MonoBehaviour _monoBehaviour, FuncCallback0 fn0, float delay = -1)
 {
     if (delay < 0)
     {
         fn0();
     }
     else
     {
         _monoBehaviour.StartCoroutine(_monoBehaviour.DelayedCoroutine(fn0, delay));
     }
 }
    public static IEnumerator DelayedCoroutine(this MonoBehaviour _monoBehaviour, FuncCallback0 callback, float delayBefore = -1)
    {
        if (delayBefore > 0)
        {
            yield return(new WaitForSeconds(delayBefore));
        }
        else if (delayBefore == 0)
        {
            yield return(new WaitForEndOfFrame());
        }

        if (callback != null)
        {
            callback();
        }
    }
Ejemplo n.º 4
0
 public virtual void Hide(bool playAnimation = true, FuncCallback0 onReadyCallback = null)
 {
     _hideReadyCallback = onReadyCallback;
     if (playAnimation && _Animator != null)
     {
         _Animator.Play(HIDE_STATE);
     }
     else
     {
         if (_UIType == UITypeEnum.UI_UNKNOWN)
         {
             onHideReady();
         }
         else
         {
             GIIControlCenter.Instance.FireEvent(UIEvents.Event(_UIType, UIEventEnum.HIDE_READY));
         }
     }
 }
Ejemplo n.º 5
0
    public virtual void Show(bool playAnimation = true, FuncCallback0 onReadyCallback = null)
    {
        _showReadyCallback = onReadyCallback;
        if (_Canvas != null)
        {
            _Canvas.SetActive(true);
        }
        gameObject.SetActive(true);

        UpdateData();

        GIIControlCenter.Instance.RegisterEventObserverEx(this);          // BUG:直接显示在屏幕上的UI可能因为没有注册消息,导致无法关闭
        if (playAnimation && _Animator != null)
        {
            _Animator.Play(SHOW_STATE);
        }
        else
        {
            GIIControlCenter.Instance.FireEvent(UIEvents.Event(_UIType, UIEventEnum.SHOW_READY));
//			onShowReady ();
        }
    }
Ejemplo n.º 6
0
    public virtual bool ExecuteInCommandCenter(IGIICommandCenter commandCenter)
    {
        if (_execution != null)
        {
            // TODO: GIIControlCenter作为外部参数传入更合适
            commandCenter.BeginProcessingCommand(Name);

                        #if UNITY_EDITOR
            Debug.LogFormat("[{0}] => Execute", _name);
                        #endif

            _execution();
            commandCenter.EndProcessingCommand(Name);
            // 只执行一次
            _execution = null;
        }

        if (NeedsClosure())
        {
            _closed = false;

                        #if UNITY_EDITOR
            Debug.LogFormat("[{0}] => Waiting for closure: {1}", _name, _closure);
                        #endif
        }
        else
        {
            _closed = true;

                        #if UNITY_EDITOR
            Debug.LogFormat("[{0}] => Finish", Name, _closure);
                        #endif
        }

        return(_closed);
    }