|
@@ -37,6 +37,7 @@ namespace GFGGame
|
|
|
private Vector2 firstTouchLastPos = Vector2.zero;//第一根手指上一次的位置
|
|
|
private Vector2 secondTouchLastPos = Vector2.zero;//第二根手指上一次的位置
|
|
|
|
|
|
+ private SwipeGesture swipeGesture;
|
|
|
private PinchGesture pinchGesture;
|
|
|
private RotationGesture rotationGesture;
|
|
|
protected override void OnInit()
|
|
@@ -80,9 +81,10 @@ namespace GFGGame
|
|
|
npcParent = _sceneObject.transform.Find("Scene/Npc").gameObject;
|
|
|
borderParent = _sceneObject.transform.Find("Border").gameObject;
|
|
|
}
|
|
|
- pinchGesture = new PinchGesture(_ui.m_comSelectBox.target);
|
|
|
+
|
|
|
+ pinchGesture = new PinchGesture(_ui.target);
|
|
|
pinchGesture.onAction.Add(OnPinch);
|
|
|
- rotationGesture = new RotationGesture(_ui.m_comSelectBox.target);
|
|
|
+ rotationGesture = new RotationGesture(_ui.target);
|
|
|
rotationGesture.onAction.Add(OnRotate);
|
|
|
|
|
|
_ui.m_ComSelectRes.m_c1.selectedIndex = 0;
|
|
@@ -167,17 +169,8 @@ namespace GFGGame
|
|
|
{
|
|
|
context.CaptureTouch();
|
|
|
if (_ui.m_ComSelectRes.target.visible == true) return;
|
|
|
-
|
|
|
- if (context.inputEvent.touchId == 0)
|
|
|
- {
|
|
|
- firstTouchLastPos = Stage.inst.touchPosition;
|
|
|
- }
|
|
|
- else if (context.inputEvent.touchId == 1)
|
|
|
- {
|
|
|
- secondTouchLastPos = Stage.inst.touchPosition;
|
|
|
- }
|
|
|
-
|
|
|
if (context.inputEvent.touchId != 0) return;
|
|
|
+
|
|
|
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
|
|
|
if (hit.collider != null)
|
|
|
{
|
|
@@ -199,36 +192,21 @@ namespace GFGGame
|
|
|
{
|
|
|
if (hitParentGameObj == null) return;//未选中任何物体
|
|
|
if (Stage.inst.touchCount > MaxTouchCount) return;//只监听两根手指
|
|
|
- string state = GetTransformState();
|
|
|
- if (state == MOVE)
|
|
|
- {
|
|
|
- ControllerObjectPos(hitParentGameObj);
|
|
|
- ControllerSelectBoxPos(hitParentGameObj);
|
|
|
- }
|
|
|
- else if (state == ROTATION)
|
|
|
- {
|
|
|
- // Vector2 lastTransform = secondTouchLastPos - firstTouchLastPos;
|
|
|
- // Vector2 curTransform = Stage.inst.GetTouchPosition(1) - Stage.inst.GetTouchPosition(0);
|
|
|
- // float angle = SceneController.GetRotationAngle(lastTransform, curTransform);
|
|
|
- // _ui.m_comSelectBox.target.rotation += angle;
|
|
|
- // hitParentGameObj.transform.rotation = Quaternion.Euler(new Vector3(hitParentGameObj.transform.rotation.x, hitParentGameObj.transform.rotation.y, hitParentGameObj.transform.rotation.z + angle));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // Vector2 lastTransform = secondTouchLastPos - firstTouchLastPos;
|
|
|
- // Vector2 curTransform = Stage.inst.GetTouchPosition(1) - Stage.inst.GetTouchPosition(0);
|
|
|
- // float scale = curTransform.magnitude / lastTransform.magnitude;
|
|
|
- // _ui.m_comSelectBox.target.SetScale(scale, scale);
|
|
|
- // hitParentGameObj.transform.localScale = new Vector3(scale, scale, scale);
|
|
|
- }
|
|
|
+
|
|
|
+ ControllerObjectPos(hitParentGameObj);
|
|
|
+ ControllerSelectBoxPos(hitParentGameObj);
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
private void OnPinch(EventContext context)
|
|
|
{
|
|
|
+
|
|
|
GTween.Kill(hitParentGameObj);
|
|
|
|
|
|
PinchGesture gesture = (PinchGesture)context.sender;
|
|
|
float newValue = Mathf.Clamp(hitParentGameObj.transform.localScale.x + gesture.delta, 0.3f, 2);
|
|
|
hitParentGameObj.transform.localScale = new Vector3(newValue, newValue, newValue);
|
|
|
+ _ui.m_comSelectBox.target.SetScale(newValue, newValue);
|
|
|
}
|
|
|
|
|
|
private void OnRotate(EventContext context)
|
|
@@ -237,12 +215,12 @@ namespace GFGGame
|
|
|
|
|
|
RotationGesture gesture = (RotationGesture)context.sender;
|
|
|
hitParentGameObj.transform.Rotate(Vector3.forward, -gesture.delta, Space.World);
|
|
|
+ _ui.m_comSelectBox.target.rotation = -gesture.delta;
|
|
|
}
|
|
|
|
|
|
private void OnClickUIEnd(EventContext context)
|
|
|
{
|
|
|
- hitParentGameObj = null;
|
|
|
- firstTouchLastPos = Vector3.zero;
|
|
|
+ if (context.inputEvent.touchId == 0) hitParentGameObj = null;
|
|
|
}
|
|
|
|
|
|
|