public static IDisposable OnClick(this Button button, SceneSharedParameter sharedParameter, Func <UniTask> call)
        {
            UnityAction wappedCall = async() =>
            {
                try
                {
                    if (sharedParameter.CanInput)
                    {
                        return;
                    }

                    sharedParameter.CanInput = true;

                    await call();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    sharedParameter.CanInput = false;
                }
            };

            button.onClick.AddListener(wappedCall);

            return(Disposable.Create(() => button.onClick.RemoveListener(wappedCall))
                   .AddTo(sharedParameter.Subscriptions));
        }
Beispiel #2
0
        public static void OnClick(this Button button, SceneSharedParameter sharedParameter, Func <Task> call)
        {
            UnityAction wappedCall = async() =>
            {
                try
                {
                    if (sharedParameter.InputLock)
                    {
                        return;
                    }

                    sharedParameter.InputLock = true;

                    await call();

                    sharedParameter.InputLock = false;
                }
                catch (Exception e)
                {
                    sharedParameter.Logger.LogException(e);
                }
            };

            button.onClick.AddListener(wappedCall);
        }
Beispiel #3
0
 public SceneBase()
 {
     this.SceneShared = new SceneSharedParameter();
 }