Skip to content

Commit

Permalink
Add LongPressGesture.holdRangeRadius
Browse files Browse the repository at this point in the history
  • Loading branch information
ytom committed Nov 30, 2016
1 parent 0a82f02 commit 3af776c
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Source/Scripts/Editor/EditorToolSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static void CreatePanel()
int layer = LayerMask.NameToLayer(StageCamera.LayerName);
panelObject.layer = layer;
}
panelObject.AddComponent<UIPanel>();
panelObject.AddComponent<FairyGUI.UIPanel>();
Selection.objects = new Object[] { panelObject };
}

Expand Down
1 change: 0 additions & 1 deletion Source/Scripts/Editor/PackagesWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using UnityEditor.SceneManagement;
#endif
using FairyGUI;
using FairyGUI.Utils;

namespace FairyGUIEditor
{
Expand Down
3 changes: 1 addition & 2 deletions Source/Scripts/Editor/UIConfigEditor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEditor;
using FairyGUI;

Expand Down
4 changes: 1 addition & 3 deletions Source/Scripts/Editor/UIPainterEditor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
#if UNITY_5_3_OR_NEWER
using UnityEditor.SceneManagement;
#endif
Expand Down
15 changes: 6 additions & 9 deletions Source/Scripts/Editor/UIPanelEditor.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
#if UNITY_5_3_OR_NEWER
using UnityEditor.SceneManagement;
#endif
using UnityEditor;
using FairyGUI;

namespace FairyGUIEditor
{
/// <summary>
///
/// </summary>
[CustomEditor(typeof(UIPanel))]
[CustomEditor(typeof(FairyGUI.UIPanel))]
public class UIPanelEditor : Editor
{
SerializedProperty packageName;
Expand Down Expand Up @@ -61,7 +58,7 @@ public override void OnInspectorGUI()
{
serializedObject.Update();

UIPanel panel = target as UIPanel;
FairyGUI.UIPanel panel = target as FairyGUI.UIPanel;
#if UNITY_5
DrawPropertiesExcluding(serializedObject, propertyToExclude);
#endif
Expand Down Expand Up @@ -107,21 +104,21 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(scale);
EditorGUILayout.Space();

FitScreen oldFitScreen = (FitScreen)fitScreen.enumValueIndex;
FairyGUI.FitScreen oldFitScreen = (FairyGUI.FitScreen)fitScreen.enumValueIndex;
EditorGUILayout.PropertyField(fitScreen);

if (serializedObject.ApplyModifiedProperties())
{
if (PrefabUtility.GetPrefabType(panel) != PrefabType.Prefab)
{
panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder, (FitScreen)fitScreen.enumValueIndex != oldFitScreen);
panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder, (FairyGUI.FitScreen)fitScreen.enumValueIndex != oldFitScreen);
}
}
}

void OnSceneGUI()
{
UIPanel panel = (target as UIPanel);
FairyGUI.UIPanel panel = (target as FairyGUI.UIPanel);
if (panel.container == null)
return;

Expand Down
13 changes: 9 additions & 4 deletions Source/Scripts/Gesture/LongPressGesture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public class LongPressGesture : EventDispatcher
/// </summary>
public bool once;

/// <summary>
/// 手指按住后,移动超出此半径范围则手势停止。
/// </summary>
public int holdRangeRadius;

GObject _host;
Vector2 _startPoint;
bool _started;
Expand All @@ -49,6 +54,7 @@ public LongPressGesture(GObject host)
_host = host;
trigger = TRIGGER;
interval = INTERVAL;
holdRangeRadius = 50;
Enable(true);

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

void __timer(object param)
{
Vector2 pt = Stage.inst.touchPosition;
pt = _host.GlobalToLocal(pt) - _startPoint;
if (Mathf.Abs(pt.x) > UIConfig.touchDragSensitivity || Mathf.Abs(pt.y) > UIConfig.touchDragSensitivity)
Vector2 pt = _host.GlobalToLocal(Stage.inst.touchPosition);
if (Mathf.Pow(pt.x - _startPoint.x, 2) + Mathf.Pow(pt.y - _startPoint.y, 2) > Mathf.Pow(holdRangeRadius, 2))
{
Timers.inst.Remove(__timer);
return;
Expand All @@ -107,7 +112,7 @@ void __timer(object param)
_started = true;
onBegin.Call();

if(!once)
if (!once)
Timers.inst.Add(interval, 0, __timer);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Scripts/UI/GList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ void HandleScroll3(bool forceUpdate)
itemRenderer(i % _numItems, ii.obj);

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

//释放未使用的
Expand Down
1 change: 0 additions & 1 deletion Source/Scripts/UI/UIPanel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI.Utils;

namespace FairyGUI
{
Expand Down

0 comments on commit 3af776c

Please sign in to comment.