Browse Source

换装界面长按显示详细信息改成1秒

guodong 1 năm trước cách đây
mục cha
commit
7364c9d505

+ 28 - 0
GameClient/Assets/Game/HotUpdate/Views/DressUp/DressUpView.cs

@@ -3,6 +3,7 @@ using FairyGUI;
 using UnityEngine;
 using System.Collections.Generic;
 using ET;
+using System;
 
 namespace GFGGame
 {
@@ -35,6 +36,11 @@ namespace GFGGame
         private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
         private int currentIndex = 0;
 
+        //用于记录任意列表是否滚动,来阻断长按事件
+        private bool listScrolled = false;
+        //用来阻断长按后的点击事件
+        private bool longPressed = false;
+
         public override void Dispose()
         {
             if (_sceneObject != null)
@@ -108,7 +114,23 @@ namespace GFGGame
             _ui.m_partsList2.m_comboBoxRarity.visible = false;
             _ui.m_partsList2.m_imgTop.visible = true;
             _ui.m_partsList.m_imgTop.visible = false;
+            _ui.m_partsList.m_list.scrollPane.onScroll.Add(OnListScroll);
+            GRoot.inst.onTouchBegin.Add(onTouchBegin);
+        }
+
+        private void onTouchBegin(EventContext context)
+        {
+            LogUtil.LogEditor("onTouchBegin");
+            listScrolled = false;
+            longPressed = false;
         }
+
+        private void OnListScroll(EventContext context)
+        {
+            LogUtil.LogEditor("OnListScroll");
+            listScrolled = true;
+        }
+
         private void InitLists()
         {
             _ui.m_comListType2.m_listType.itemRenderer = ListType2Item;
@@ -285,6 +307,8 @@ namespace GFGGame
 
         private void OnClickPartsListItem(EventContext context)
         {
+            LogUtil.LogEditor("OnClickPartsListItem");
+            if (longPressed) return;
             if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
             {
                 return;
@@ -342,6 +366,7 @@ namespace GFGGame
 
         private void OnClickSuitPartsListItem(EventContext context)
         {
+            if (longPressed) return;
             if (ViewManager.isViewOpen(typeof(DressUpItemTipsView).FullName))
             {
                 return;
@@ -381,6 +406,9 @@ namespace GFGGame
 
         private void OnLongPress(EventContext context)
         {
+            LogUtil.LogEditor($"OnLongPress {listScrolled}");
+            if (listScrolled) return;
+            longPressed = true;
             LongPressGesture gesture = (LongPressGesture)context.sender;
             int itemId = (int)gesture.host.data;
             GoodsItemTipsController.ShowItemTips(itemId);