zhaoyang 3 年之前
父節點
當前提交
d4267a93b3

+ 1 - 1
FGUIProject/assets/DressUp/ComChecked.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<component size="446,291" pivot="0.5,0.5" anchor="true">
+<component size="446,291">
   <displayList>
     <image id="n9_g3xa" name="n9" src="7dea4g" fileName="images/kp_kprk_4.png" xy="32,35" size="381,220">
       <relation target="" sidePair="width-width,height-height"/>

+ 1 - 1
FGUIProject/assets/DressUp/PhotographUI.xml

@@ -5,6 +5,6 @@
     <component id="n1_yd72" name="btnBack" src="9xlo8" fileName="components/ButtonBack1.xml" pkg="eg2y0ldp" xy="35,80"/>
     <component id="n6_g3xa" name="btnChoose" src="g3xa4h" fileName="components/Button8.xml" xy="972,1016"/>
     <component id="n5_7dea" name="ComSelectRes" src="7dea4f" fileName="components/ComSelect.xml" xy="30,1174"/>
-    <component id="n9_g3xa" name="comSelectBox" src="g3xa4l" fileName="ComChecked.xml" xy="0,0" size="382,450"/>
+    <component id="n9_g3xa" name="comSelectBox" src="g3xa4l" fileName="ComChecked.xml" xy="388,295" size="382,450"/>
   </displayList>
 </component>

+ 24 - 52
GameClient/Assets/Game/HotUpdate/Views/DressUp/PhotographView.cs

@@ -18,7 +18,8 @@ namespace GFGGame
         private const string MOVE = "MOVE";
         private const string SCALE = "SCALE";
         private const string ROTATION = "ROTATION";
-        private const int MaxTouchCount = 2;
+        private const float MaxScale = 2;
+        private const float MinScale = 0.1f;
 
         private GameObject bodyParent;
         private GameObject bgParent;
@@ -34,9 +35,6 @@ namespace GFGGame
         private GameObject hitParentGameObj;//当前选中的父物体(需要进行移动缩放旋转的物体)
         private Vector3 distance = Vector3.zero;//点击位置和点击物体原点的距离,用于
 
-        private Vector2 firstTouchLastPos = Vector2.zero;//第一根手指上一次的位置
-        private Vector2 secondTouchLastPos = Vector2.zero;//第二根手指上一次的位置
-
         private SwipeGesture swipeGesture;
         private PinchGesture pinchGesture;
         private RotationGesture rotationGesture;
@@ -191,40 +189,17 @@ namespace GFGGame
         private void OnClickUIMove(EventContext context)
         {
             if (hitParentGameObj == null) return;//未选中任何物体
-            if (Stage.inst.touchCount > MaxTouchCount) return;//只监听两根手指
+            if (Stage.inst.touchCount > 1) return;//只监听1根手指
 
             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)
-        {
-            GTween.Kill(hitParentGameObj.transform);
-
-            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)
         {
             if (context.inputEvent.touchId == 0) hitParentGameObj = null;
         }
 
-
-
         //选中物体的位置
         private void ControllerObjectPos(GameObject hitParentGameObj)
         {
@@ -254,41 +229,38 @@ namespace GFGGame
                 }
             }
         }
-        //选中框的大小位置旋转
+        //选中框的位置
         private void ControllerSelectBoxPos(GameObject hitParentGameObj)
         {
             SceneController.SetGameObjectCenter(hitParentGameObj);
             //位置:角色、道具、npc全用对应父物体的位置
             Vector2 objScreenPos = Camera.main.WorldToScreenPoint(hitParentGameObj.transform.position);
-            Vector2 localPos = new Vector2(objScreenPos.x, Screen.height - objScreenPos.y);
-            _ui.m_comSelectBox.target.SetXY(localPos.x, localPos.y);
+            // Vector2 localPos = new Vector2(objScreenPos.x + _ui.m_comSelectBox.target.width * 0.5f, (Screen.height - objScreenPos.y) + _ui.m_comSelectBox.target.height * 0.5f);
+            Vector2 localPos = new Vector2(objScreenPos.x, (Screen.height - objScreenPos.y));
+            _ui.m_comSelectBox.target.position = localPos;//(localPos.x, localPos.y);
 
         }
 
-        private string GetTransformState()
+        private void OnPinch(EventContext context)
         {
-            if (Stage.inst.touchCount == 1) return MOVE;//一根手指只能移动
+            if (hitParentGameObj == null) return;
+            GTween.Kill(hitParentGameObj);
 
-            Vector2 lastDistance = secondTouchLastPos - firstTouchLastPos;
-            Vector2 curDistance = Stage.inst.GetTouchPosition(1) - Stage.inst.GetTouchPosition(0);
+            PinchGesture gesture = (PinchGesture)context.sender;
+            float newValue = Mathf.Clamp(hitParentGameObj.transform.localScale.x + gesture.delta, 0.3f, 2);
+            if (newValue > MaxScale || newValue < MinScale) return;
+            hitParentGameObj.transform.localScale = new Vector3(newValue, newValue, newValue);
+            _ui.m_comSelectBox.target.SetScale(newValue, newValue);
+        }
 
-            if (lastDistance == curDistance)
-            {
-                return MOVE;//向量大小和方向都不变是位移
-            }
-            else
-            {
-                if (lastDistance.magnitude != curDistance.magnitude)
-                {
-                    //两指距离有变化是缩放
-                    return SCALE;
-                }
-                else
-                {
-                    //两指距离无变化是缩放
-                    return ROTATION;
-                }
-            }
+        private void OnRotate(EventContext context)
+        {
+            if (hitParentGameObj == null) return;
+            GTween.Kill(hitParentGameObj.transform);
+
+            RotationGesture gesture = (RotationGesture)context.sender;
+            hitParentGameObj.transform.Rotate(Vector3.forward, -gesture.delta, Space.World);
+            _ui.m_comSelectBox.target.rotation = -gesture.delta;
         }
         //背景
         private void UpdateBgOrNpcOrBorder(EnumPhotographType type, int itemId)

二進制
GameClient/Assets/ResIn/UI/DressUp/DressUp_fui.bytes