Skip to content

ロングタップのみを実装するように変更#1

Open
dwl398 wants to merge 4 commits intopaldynojosh:masterfrom
dwl398:fix/refactor_long_tap_button
Open

ロングタップのみを実装するように変更#1
dwl398 wants to merge 4 commits intopaldynojosh:masterfrom
dwl398:fix/refactor_long_tap_button

Conversation

@dwl398
Copy link
Copy Markdown

@dwl398 dwl398 commented Feb 22, 2022

サンプルの実装を見てなくて押下後の経過時間などに一ミリも対応できてないので全然使えないです
ロングタップの部分だけもっと簡潔に書けそうだなーと思ってPR作成したので参考になれば!

[RequireComponent(typeof(Graphic))]
public class LongTapEventHandler : MonoBehaviour
{
[SerializeField] private Graphic _raycastImage;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RequireComponent(typeof(Graphic))]があるので無駄なシリアライズを削除しました

Comment on lines +44 to +45
var time = Time.time;
await _raycastImage.OnPointerUpAsObservable().Take(1).ToUniTask(cancellationToken: cancellationToken);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1回だけポインターアップのイベントが発行されるのを待つ
他にもポインターが領域外に行くとか色々ダメになる条件はあるけど
それ系の追加はサボりました

await _raycastImage.OnPointerUpAsObservable().Take(1).ToUniTask(cancellationToken: cancellationToken);

try
if (_delayStartLongTap + _fireLongTapTime < Time.time - time)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

公開するイベントがロングタップだけなら _fireLongTapTimeだけでヨサソウ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant