Skip to content

Commit 3af776c

Browse files
author
ytom
committed
Add LongPressGesture.holdRangeRadius
1 parent 0a82f02 commit 3af776c

File tree

8 files changed

+19
-22
lines changed

8 files changed

+19
-22
lines changed

Source/Scripts/Editor/EditorToolSet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void CreatePanel()
4242
int layer = LayerMask.NameToLayer(StageCamera.LayerName);
4343
panelObject.layer = layer;
4444
}
45-
panelObject.AddComponent<UIPanel>();
45+
panelObject.AddComponent<FairyGUI.UIPanel>();
4646
Selection.objects = new Object[] { panelObject };
4747
}
4848

Source/Scripts/Editor/PackagesWindow.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using UnityEditor.SceneManagement;
88
#endif
99
using FairyGUI;
10-
using FairyGUI.Utils;
1110

1211
namespace FairyGUIEditor
1312
{

Source/Scripts/Editor/UIConfigEditor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections.Generic;
2-
using UnityEngine;
1+
using UnityEngine;
32
using UnityEditor;
43
using FairyGUI;
54

Source/Scripts/Editor/UIPainterEditor.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using UnityEngine;
1+
using UnityEngine;
42
#if UNITY_5_3_OR_NEWER
53
using UnityEditor.SceneManagement;
64
#endif

Source/Scripts/Editor/UIPanelEditor.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using UnityEngine;
1+
using UnityEngine;
42
#if UNITY_5_3_OR_NEWER
53
using UnityEditor.SceneManagement;
64
#endif
75
using UnityEditor;
8-
using FairyGUI;
96

107
namespace FairyGUIEditor
118
{
129
/// <summary>
1310
///
1411
/// </summary>
15-
[CustomEditor(typeof(UIPanel))]
12+
[CustomEditor(typeof(FairyGUI.UIPanel))]
1613
public class UIPanelEditor : Editor
1714
{
1815
SerializedProperty packageName;
@@ -61,7 +58,7 @@ public override void OnInspectorGUI()
6158
{
6259
serializedObject.Update();
6360

64-
UIPanel panel = target as UIPanel;
61+
FairyGUI.UIPanel panel = target as FairyGUI.UIPanel;
6562
#if UNITY_5
6663
DrawPropertiesExcluding(serializedObject, propertyToExclude);
6764
#endif
@@ -107,21 +104,21 @@ public override void OnInspectorGUI()
107104
EditorGUILayout.PropertyField(scale);
108105
EditorGUILayout.Space();
109106

110-
FitScreen oldFitScreen = (FitScreen)fitScreen.enumValueIndex;
107+
FairyGUI.FitScreen oldFitScreen = (FairyGUI.FitScreen)fitScreen.enumValueIndex;
111108
EditorGUILayout.PropertyField(fitScreen);
112109

113110
if (serializedObject.ApplyModifiedProperties())
114111
{
115112
if (PrefabUtility.GetPrefabType(panel) != PrefabType.Prefab)
116113
{
117-
panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder, (FitScreen)fitScreen.enumValueIndex != oldFitScreen);
114+
panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder, (FairyGUI.FitScreen)fitScreen.enumValueIndex != oldFitScreen);
118115
}
119116
}
120117
}
121118

122119
void OnSceneGUI()
123120
{
124-
UIPanel panel = (target as UIPanel);
121+
FairyGUI.UIPanel panel = (target as FairyGUI.UIPanel);
125122
if (panel.container == null)
126123
return;
127124

Source/Scripts/Gesture/LongPressGesture.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public class LongPressGesture : EventDispatcher
3737
/// </summary>
3838
public bool once;
3939

40+
/// <summary>
41+
/// 手指按住后,移动超出此半径范围则手势停止。
42+
/// </summary>
43+
public int holdRangeRadius;
44+
4045
GObject _host;
4146
Vector2 _startPoint;
4247
bool _started;
@@ -49,6 +54,7 @@ public LongPressGesture(GObject host)
4954
_host = host;
5055
trigger = TRIGGER;
5156
interval = INTERVAL;
57+
holdRangeRadius = 50;
5258
Enable(true);
5359

5460
onBegin = new EventListener(this, "onLongPressBegin");
@@ -95,9 +101,8 @@ void __touchBegin(EventContext context)
95101

96102
void __timer(object param)
97103
{
98-
Vector2 pt = Stage.inst.touchPosition;
99-
pt = _host.GlobalToLocal(pt) - _startPoint;
100-
if (Mathf.Abs(pt.x) > UIConfig.touchDragSensitivity || Mathf.Abs(pt.y) > UIConfig.touchDragSensitivity)
104+
Vector2 pt = _host.GlobalToLocal(Stage.inst.touchPosition);
105+
if (Mathf.Pow(pt.x - _startPoint.x, 2) + Mathf.Pow(pt.y - _startPoint.y, 2) > Mathf.Pow(holdRangeRadius, 2))
101106
{
102107
Timers.inst.Remove(__timer);
103108
return;
@@ -107,7 +112,7 @@ void __timer(object param)
107112
_started = true;
108113
onBegin.Call();
109114

110-
if(!once)
115+
if (!once)
111116
Timers.inst.Add(interval, 0, __timer);
112117
}
113118

Source/Scripts/UI/GList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,7 @@ void HandleScroll3(bool forceUpdate)
19531953
itemRenderer(i % _numItems, ii.obj);
19541954

19551955
ii.obj.SetXY((int)(i / pageSize) * viewWidth + col * (ii.size.x + _columnGap),
1956-
(i / _curLineItemCount) % _curLineItemCount2 * (ii.size.y + _lineGap));
1956+
(int)(i / _curLineItemCount) % _curLineItemCount2 * (ii.size.y + _lineGap));
19571957
}
19581958

19591959
//释放未使用的

Source/Scripts/UI/UIPanel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using UnityEngine;
4-
using FairyGUI.Utils;
54

65
namespace FairyGUI
76
{

0 commit comments

Comments
 (0)