カスタマイズ機能長押し対応
This commit is contained in:
parent
7430e815af
commit
fe48169373
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
|
@ -24,8 +25,8 @@ namespace MyGame.Scenes.marketing.Scripts
|
|||
[SerializeField] private Text unlockLevelText;
|
||||
[SerializeField] private Text priceText;
|
||||
[SerializeField] private Transform iconTarget;
|
||||
float pressTime = .5f;
|
||||
|
||||
private IObservable<Unit> ClickObservable => button.OnClickAsObservable().TakeUntilDestroy(this);
|
||||
public IObservable<Unit> PurchaseObservable => purchaseSubject;
|
||||
private readonly Subject<Unit> purchaseSubject = new Subject<Unit>();
|
||||
public IObservable<Unit> SelectObservable => selectSubject;
|
||||
|
|
@ -49,7 +50,24 @@ namespace MyGame.Scenes.marketing.Scripts
|
|||
selectedFrameObject.SetActive(state == ShopCustomizeItemState.Selected);
|
||||
unselectedObject.SetActive(state == ShopCustomizeItemState.Purchased);
|
||||
}).AddTo(this);
|
||||
ClickObservable.ThrottleFirst(TimeSpan.FromSeconds(.2f)).Subscribe(_ =>
|
||||
|
||||
button.OnPointerDownAsObservable()
|
||||
.Select(_ =>
|
||||
Observable.Amb(
|
||||
Observable.Timer(TimeSpan.FromSeconds(pressTime)).Select(x => true),
|
||||
button.OnPointerUpAsObservable().Select(x => false))
|
||||
)
|
||||
.Switch()
|
||||
.Subscribe(longPress =>
|
||||
{
|
||||
if (longPress)
|
||||
{
|
||||
if (itemState.Value == ShopCustomizeItemState.Purchased)
|
||||
{
|
||||
detailSubject.OnNext(Unit.Default);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (itemState.Value)
|
||||
{
|
||||
|
|
@ -67,6 +85,7 @@ namespace MyGame.Scenes.marketing.Scripts
|
|||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}).AddTo(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue