Commit 20faca7d authored by JiangWanZhi's avatar JiangWanZhi

修改一下缩放,拖动的逻辑

parent 914f895e
......@@ -101,18 +101,18 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 165307577509819478}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1633357141748549960}
m_Father: {fileID: 7778848243247776032}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -41, y: -1582}
m_SizeDelta: {x: 0, y: 800}
m_AnchoredPosition: {x: -41, y: -1302.4723}
m_SizeDelta: {x: 0, y: 1234.2775}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1520829811932201433
CanvasRenderer:
......@@ -280,11 +280,10 @@ RectTransform:
- {fileID: 9202005404466210624}
- {fileID: 3684281432546734940}
- {fileID: 2488998574890369715}
- {fileID: 216671789900275948}
- {fileID: 4207755507653322023}
- {fileID: 7778848243247776032}
- {fileID: 4930126960711289547}
- {fileID: 4350987738922043080}
- {fileID: 2225806379496700186}
m_Father: {fileID: 0}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -595,6 +594,46 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &615370486041879482
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2225806379496700186}
m_Layer: 5
m_Name: GameArea
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2225806379496700186
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 615370486041879482}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3935196267496203719}
- {fileID: 4587279003709612060}
- {fileID: 6771378527872526214}
- {fileID: 2406719830949511634}
m_Father: {fileID: 1633357141748549960}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &873009014252909700
GameObject:
m_ObjectHideFlags: 0
......@@ -1022,12 +1061,12 @@ RectTransform:
- {fileID: 3345813486746951798}
- {fileID: 161008593911248317}
- {fileID: 1976999355571500960}
m_Father: {fileID: 1633357141748549960}
m_Father: {fileID: 7778848243247776032}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 348}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 100}
m_SizeDelta: {x: 750, y: 25}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1036549963076789408
......@@ -1270,6 +1309,42 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &2666167341498499835
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3935196267496203719}
m_Layer: 5
m_Name: Pos_Left_Up
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3935196267496203719
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2666167341498499835}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2225806379496700186}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &2929582902800575783
GameObject:
m_ObjectHideFlags: 0
......@@ -2500,6 +2575,42 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &5586756016372078258
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2406719830949511634}
m_Layer: 5
m_Name: Pos_Left_Down
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2406719830949511634
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5586756016372078258}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2225806379496700186}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 270}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &5697974217771189481
GameObject:
m_ObjectHideFlags: 0
......@@ -3554,8 +3665,10 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 216671789900275948}
- {fileID: 1682976293997861255}
- {fileID: 9072884845680009661}
- {fileID: 4207755507653322023}
m_Father: {fileID: 1633357141748549960}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -3859,6 +3972,42 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &8764365333959496128
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4587279003709612060}
m_Layer: 5
m_Name: Pos_Right_Up
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4587279003709612060
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8764365333959496128}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2225806379496700186}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &8896268844625087083
GameObject:
m_ObjectHideFlags: 0
......@@ -4107,6 +4256,42 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &9139019227740239578
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6771378527872526214}
m_Layer: 5
m_Name: Pos_Right_Down
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6771378527872526214
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9139019227740239578}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2225806379496700186}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: 0, y: 270}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1001 &157988101985480200
PrefabInstance:
m_ObjectHideFlags: 0
......
......@@ -174,7 +174,7 @@ MonoBehaviour:
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 0
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
......
......@@ -123,6 +123,11 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!224 &47226757 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 832333741895004512, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
m_PrefabInstance: {fileID: 1821187684178258737}
m_PrefabAsset: {fileID: 0}
--- !u!1 &92769422
GameObject:
m_ObjectHideFlags: 0
......@@ -263,7 +268,7 @@ Camera:
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
far clip plane: 100000
field of view: 60
orthographic: 1
orthographic size: 5
......@@ -290,11 +295,10 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 297775245}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalPosition: {x: 0, y: 0, z: -69.8}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1474894691}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -363,6 +367,11 @@ MonoBehaviour:
MaxScale: 8
Min_Move: 0.5
Max_Move: 10
AreaPoint_Right_Up: {fileID: 1064148216}
AreaPoint_Left_Down: {fileID: 1090237499}
TipBtn: {fileID: 1821187684178258741}
AutoBtn: {fileID: 47226757}
CloseBtn: {fileID: 669974489}
--- !u!224 &464840817 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 4930126960711289547, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
......@@ -434,8 +443,23 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!224 &669974489 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 5446485606855009903, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
m_PrefabInstance: {fileID: 1821187684178258737}
m_PrefabAsset: {fileID: 0}
--- !u!224 &1064148216 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 4587279003709612060, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
m_PrefabInstance: {fileID: 1821187684178258737}
m_PrefabAsset: {fileID: 0}
--- !u!224 &1090237499 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 2406719830949511634, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
m_PrefabInstance: {fileID: 1821187684178258737}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1329740667
GameObject:
m_ObjectHideFlags: 0
......@@ -512,11 +536,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1329740667}
m_CullTransparentMesh: 1
--- !u!224 &1474894691 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1633357141748549960, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
m_PrefabInstance: {fileID: 1821187684178258737}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1643100473
GameObject:
m_ObjectHideFlags: 0
......@@ -680,7 +699,7 @@ PrefabInstance:
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 297775248}
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 46365302489525420, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_Layer
......@@ -736,7 +755,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 216671789900275948, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchoredPosition.y
value: -707
value: -128
objectReference: {fileID: 0}
- target: {fileID: 282682974999690270, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_Sprite
......@@ -1006,6 +1025,18 @@ PrefabInstance:
propertyPath: m_RenderMode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1237637097486733067, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_PixelPerfect
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1237637097486733067, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_PlaneDistance
value: 100
objectReference: {fileID: 0}
- target: {fileID: 1237637097486733067, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_SortingLayerID
value: -230597399
objectReference: {fileID: 0}
- target: {fileID: 1345706252318982597, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_Size
value: 1
......@@ -1028,7 +1059,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 1633357141748549960, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_RootOrder
value: -1
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1633357141748549960, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchorMax.x
......@@ -1576,7 +1607,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4207755507653322023, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchorMax.y
value: 0
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4207755507653322023, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchorMin.x
......@@ -1584,7 +1615,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4207755507653322023, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchorMin.y
value: 0
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 4207755507653322023, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_SizeDelta.x
......@@ -1596,7 +1627,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4207755507653322023, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchoredPosition.y
value: 348
value: 100
objectReference: {fileID: 0}
- target: {fileID: 4231459619420674691, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_Color.a
......@@ -1696,15 +1727,15 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5145632994799020238, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_SizeDelta.y
value: 5
value: -30
objectReference: {fileID: 0}
- target: {fileID: 5145632994799020238, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
value: -0.000030517578
objectReference: {fileID: 0}
- target: {fileID: 5145632994799020238, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
value: -35
objectReference: {fileID: 0}
- target: {fileID: 5179610333064401809, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_Layer
......@@ -1884,7 +1915,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 5970386083598165497, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5970386083598165497, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_AnchorMin.x
......@@ -2154,6 +2185,10 @@ PrefabInstance:
propertyPath: m_Layer
value: 5
objectReference: {fileID: 0}
- target: {fileID: 8969470922680416840, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9026256924356714604, guid: e2f00cfdb21d04b46adf17805f74f20c, type: 3}
propertyPath: m_SizeDelta.y
value: 0
......
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using Debug = UnityEngine.Debug;
public class ScaleToImage : MonoBehaviour
{
public Transform target; //目标
bool isInit;
bool isInit_Scale;
Vector3 touch1, touch2, oriPos, pos;
float scale, oriScale;
public float scaleSpeed = 1;
......@@ -25,8 +22,14 @@ public class ScaleToImage : MonoBehaviour
public float Min_Move;
public float Max_Move;
public Transform AreaPoint_Right_Up; // 右上
public Transform AreaPoint_Left_Down; //左下
private bool isInit_one;
public Transform TipBtn;
public Transform AutoBtn;
public Transform CloseBtn;
private bool isInit_move;
private Vector3 offset;
private Vector3 ToFigerCenter; //指向手指中间的向量
......@@ -35,14 +38,31 @@ public class ScaleToImage : MonoBehaviour
private float MoveValue; //移动,缩放大了就小一些
private bool PlayAniFlag;
private Vector3 OldPos;
private Vector3 OldPos_Move; //手指拖动上一帧的位置
private bool MoveEndFlag;
private bool IsPlayAniFlag;
private bool TestFlag;
private bool MoveFlag;
private void Update()
{
//不是双指就关闭
if (Input.touchCount != 2)
if (Input.touchCount == 2)
{
isInit = false;
if (MoveFlag)
{
MoveFlag = false;
}
Scale();
MoveEndFlag = false;
TestFlag = true;
}
else
{
isInit_Scale = false;
if (PlayAniFlag)
{
if (target.GetChild(0).localScale.x <= Min_Move) //缩放小的回大
......@@ -57,28 +77,41 @@ public class ScaleToImage : MonoBehaviour
for (int i = 0; i < target.childCount; i++)
{
target.GetChild(i).DOScale(Vector3.one * MaxScale, 0.3f);
target.GetChild(i).DOMove(oriPos, 0.3f);
target.GetChild(i).DOMove(oriPos, 0.3f).onComplete=()=> { IsPlayAniFlag = false; };
}
}
PlayAniFlag = false;
IsPlayAniFlag = true;
}
if (TestFlag)
{
//Debug.LogError($"11111 初始的位置:{oriPos} 现在的位置:{target.GetChild(0).position} 本地:{target.GetChild(0).localPosition} 初始的缩放:{oriScale} 现在的缩放:{target.GetChild(0).localScale}");
TestFlag = false;
}
Move();
}
//初始化
if (Input.touchCount == 2 && !isInit)
}
private void Scale()
{
if (!isInit_Scale)
{
if (!IsImageArea(Input.GetTouch(0).position) || !IsImageArea(Input.GetTouch(1).position))
{
isInit = false;
isInit_Scale = false;
return;
}
//两指点位
touch1 = canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position);
touch2 = canvasCamera.ScreenToWorldPoint(Input.GetTouch(1).position);
touch1 = new Vector3(touch1.x, touch1.y, 0);
touch2 = new Vector3(touch2.x, touch2.y, 0);
//目标初始点位
oriPos = new Vector3(target.GetChild(0).position.x, target.GetChild(0).position.y, 0);
float distance = Vector2.Distance(touch1, touch2) / 2f;
var normal = (touch1 - touch2).normalized;
pos = normal * distance + touch2; //两个手指中间的点
......@@ -87,102 +120,212 @@ public class ScaleToImage : MonoBehaviour
//距离
ToFigerdistance = Vector3.Distance(pos, oriPos);
oriScale = target.GetChild(0).localScale.x;//开始的缩放值
isInit = true;
isInit_Scale = true;
MoveValue = 1 / oriScale;
return;
}
if (Input.touchCount == 2)
isInit_move = false;
if (!IsImageArea(Input.GetTouch(0).position) || !IsImageArea(Input.GetTouch(1).position))
{
isInit_one = false;
if (!IsImageArea(Input.GetTouch(0).position) || !IsImageArea(Input.GetTouch(1).position))
{
isInit = false;
return;
}
isInit_Scale = false;
return;
}
//两指缩放比例
float nowdis = Vector3.Distance(canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position), canvasCamera.ScreenToWorldPoint(Input.GetTouch(1).position));
scale = nowdis / Vector3.Distance(touch1, touch2); //大于1是放大,小于是缩小
//两指缩放比例
float nowdis = Vector3.Distance(canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position), canvasCamera.ScreenToWorldPoint(Input.GetTouch(1).position));
scale = nowdis / Vector3.Distance(touch1, touch2); //大于1是放大,小于是缩小
//利用scaleSpeed控制缩放速度
scale = (scale - 1) * 0.8f; //正的话就是放大图片
if (scale < 0)
{
scale = scale * oriScale * 0.8f; //缩小速度
}
//利用scaleSpeed控制缩放速度
scale = (scale - 1) * 0.8f; //正的话就是放大图片
if (scale < 0)
if (target.GetChild(0).localScale.x < Min_Move)
{
PlayAniFlag = true;
return;
}
float scale_target = 0;
for (int i = 0; i < target.childCount; i++)
{
var item = target.GetChild(i);
scale_target = (Vector3.one * (oriScale + scale)).x;
if (scale_target < Min_Move)
{
scale = scale * oriScale * 0.8f;
item.localScale = Vector3.one * Min_Move * 0.99f;
}
if (target.GetChild(0).localScale.x < Min_Move)
else if (scale_target > Max_Move)
{
item.localScale = Vector3.one * (oriScale + scale);
PlayAniFlag = true;
return;
}
float scale_target;
for (int i = 0; i < target.childCount; i++)
else
{
var item = target.GetChild(i);
scale_target = (Vector3.one * (oriScale + scale)).x;
if (scale_target < Min_Move)
{
item.localScale = Vector3.one * Min_Move * 0.99f;
}
else if (scale_target > Max_Move)
{
item.localScale = Vector3.one * (oriScale + scale);
PlayAniFlag = true;
}
else
item.localScale = Vector3.one * (oriScale + scale);
item.localScale = Vector3.one * (oriScale + scale);
}
//改变目标位置,让位置保持不变
item.position = oriPos - ToFigerCenter * (item.localScale.x - oriScale) * ToFigerdistance * MoveValue;
item.localPosition = new Vector3(item.localPosition.x, item.localPosition.y, 0);
}
//改变目标位置,让位置保持不变
item.position = oriPos - ToFigerCenter * (item.localScale.x - oriScale) * ToFigerdistance * MoveValue;
//Debug.LogError($"11111 目标缩放:{scale_target} 动画标记:{PlayAniFlag} Min_Move:{Min_Move} Max_Move: {Max_Move} 初始点:{oriPos} 现在点:{target.GetChild(0).position}");
}
private void Move()
{
if (Input.GetMouseButtonUp(0))
{
isInit_move = false;
if (MoveEndFlag && !IsPlayAniFlag)
LerptoMove_End();
}
else if (Input.GetMouseButtonDown(0))
{
if (IsImageArea(Input.mousePosition) && IsMidArea(Input.mousePosition))
{
MoveEndFlag = true;
}
}
else if (Input.GetMouseButton(0))
{
if(MoveEndFlag)
OnClickMove(Input.mousePosition);
}
if (Input.touchCount == 1) //单指拖动
}
private void LerptoMove_End() //移动结束后加个缓动的效果
{
MoveEndFlag = false;
var nowpos= new Vector3(target.GetChild(0).position.x, target.GetChild(0).position.y, 0);
if (nowpos != OldPos_Move)
{
if (!IsImageArea(Input.GetTouch(0).position))
var tonow = (nowpos - OldPos_Move).normalized; //指向现在位置的方向向量
var newpos = tonow*0.5f + nowpos;
for (int i = 0; i < target.childCount; i++)
{
isInit_one = false;
return;
var item = target.GetChild(i);
item.DOMove(newpos, 0.3f);
}
if (!isInit_one)
{
offset = target.GetChild(0).position - new Vector3(canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position).x, canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position).y, 0);
}
}
isInit_one = true;
private void OnClickMove(Vector2 ScreenPos)
{
if (!isInit_move)
{
if (!IsImageArea(ScreenPos))
return;
offset = new Vector3(target.GetChild(0).position.x, target.GetChild(0).position.y,0) - new Vector3(canvasCamera.ScreenToWorldPoint(ScreenPos).x, canvasCamera.ScreenToWorldPoint(ScreenPos).y, 0);
isInit_move = true;
}
else
{
var pos = new Vector3(canvasCamera.ScreenToWorldPoint(ScreenPos).x, canvasCamera.ScreenToWorldPoint(ScreenPos).y, 0) + offset; //图片目标位置
}
else
CanMove(pos.x, pos.y, out float x, out float y);
pos = new Vector3(x, y, 0);
OldPos_Move = new Vector3(target.GetChild(0).position.x, target.GetChild(0).position.y, 0);
for (int i = 0; i < target.childCount; i++)
{
var pos = new Vector3(canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position).x, canvasCamera.ScreenToWorldPoint(Input.GetTouch(0).position).y, 0) + offset;
for (int i = 0; i < target.childCount; i++)
{
var item = target.GetChild(i);
var item = target.GetChild(i);
item.position = pos;
}
MoveFlag = true;
}
}
item.position = pos;
private void CanMove(float Target_x, float Target_y, out float x, out float y)
{
float scale = target.GetChild(0).localScale.x;
scale = Mathf.Max(scale, 1);
}
}
var dis_x = AreaPoint_Right_Up.position.x - AreaPoint_Left_Down.position.x;
var dis_y = AreaPoint_Right_Up.position.y - AreaPoint_Left_Down.position.y;
}
float offset = 2.6f - 1 / scale;
float offset_y = (dis_y * scale - dis_y) / offset;
float offset_x = (dis_x * scale - dis_x) / offset;
if (Input.touchCount == 0)
if (Target_y < AreaPoint_Left_Down.position.y - offset_y)
{
y = AreaPoint_Left_Down.position.y - offset_y;
}
else if(Target_y > AreaPoint_Right_Up.position.y+ offset_y)
{
isInit_one = false;
y = AreaPoint_Right_Up.position.y+ offset_y;
}
else
{
y = Target_y;
}
if (Target_x < AreaPoint_Left_Down.position.x- offset_x)
{
x = AreaPoint_Left_Down.position.x- offset_x;
}
else if (Target_x > AreaPoint_Right_Up.position.x+ offset_x)
{
x = AreaPoint_Right_Up.position.x+ offset_x;
}
else
{
x = Target_x;
}
}
private bool IsImageArea(Vector3 screenpos) //判断这个点是不是在中间的区域
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(ScrollRect.GetComponent<RectTransform>(), screenpos, canvasCamera, out var vector); //拿到中心位置和这个图片在一个父物体下的本地坐标
return vector.y - ScrollRect.GetComponent<RectTransform>().sizeDelta.y / 2f > 0;
}
private bool IsMidArea( Vector3 screenpos) //是不是中间(不是上面三个按钮的区域)
{
if (!BtnPosJudge(TipBtn, screenpos) && !BtnPosJudge(AutoBtn, screenpos)! && !BtnPosJudge_Close(CloseBtn, screenpos))
{
return true;
}
return false;
}
private bool BtnPosJudge(Transform Btn, Vector3 screenpos)
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(Btn.GetComponent<RectTransform>(), screenpos, canvasCamera, out var vector); //拿到中心位置和这个图片在一个父物体下的本地坐标
var size = Btn.GetComponent<RectTransform>().sizeDelta / 2f;
if (vector.x <= size.x && vector.x >= -size.x && vector.y <= size.y && vector.y >= -size.y)
{
return true;
}
return false;
}
private bool BtnPosJudge_Close(Transform Btn, Vector3 screenpos)
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(Btn.GetComponent<RectTransform>(), screenpos, canvasCamera, out var vector); //拿到中心位置和这个图片在一个父物体下的本地坐标
var size = Btn.GetComponent<RectTransform>().sizeDelta;
if (vector.x <= size.x/2f && vector.x >= -size.x/2f && vector.y <= size.y && vector.y >= 0)
{
return true;
}
return false;
}
}
......@@ -83,9 +83,9 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
//gameScenUser
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
gridViewList.gameObject.SetActive(false);
transform.Find("groupListBg").gameObject.SetActive(false);
transform.Find("gameProgress/gameProgressText").gameObject.SetActive(false);
transform.Find("gameProgress").gameObject.SetActive(false);
transform.Find("areaGroupList/groupListBg").gameObject.SetActive(false);
transform.Find("areaGroupList/gameProgress/gameProgressText").gameObject.SetActive(false);
transform.Find("areaGroupList/gameProgress").gameObject.SetActive(false);
transform.Find("gameEndOperBase").gameObject.SetActive(false);
transform.Find("gameEndOperBase").GetComponent<gameEndLogic>().initMember();
transform.Find("areaGroupList/tipSelectGroup").gameObject.SetActive(false);
......@@ -148,11 +148,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
void Update()
{
ActionManages.update();
if (Input.GetKeyDown(KeyCode.A))
{
Debug.LogError(utilsTools.DisplaySize);
}
}
//创建列表item的时候回调并设置、初始化和刷新
......@@ -319,7 +314,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
return;
}
areaGroupList.SetActive(true);
transform.Find("groupListBg").gameObject.SetActive(true);
transform.Find("areaGroupList/groupListBg").gameObject.SetActive(true);
if (autoSwitchGroup == false) nowidx = -1;
var cellSize = gridViewList.getCellSize();
gradViewBack gradView = (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) => {
......@@ -449,9 +444,9 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
transform.Find("ingameLoad").gameObject.SetActive(false);
transform.Find("top").gameObject.SetActive(true);
utilsTools.setGDataByKey("loadingEnd", utilsTools.getTotalMillisecond());
RectTransform transform1 = transform.Find("gameProgress/gameProgressText").GetComponent<RectTransform>();
RectTransform transform1 = transform.Find("areaGroupList/gameProgress/gameProgressText").GetComponent<RectTransform>();
transform1.gameObject.SetActive(true);
transform1 = transform.Find("gameProgress").GetComponent<RectTransform>();
transform1 = transform.Find("areaGroupList/gameProgress").GetComponent<RectTransform>();
transform1.gameObject.SetActive(true);
gameShowView.GetComponent<mainGameScaleMove>().setCheckInput();
gameShowView.GetComponent<mainGameView>().showTimes();
......@@ -625,9 +620,9 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
void onChangeGameUserProgressEvent(List<UnityEngine.Object> uobjects,List<System.Object> objects) {
int pro = (int)objects[0];
transform.Find("ingameLoad").gameObject.SetActive(false);
TextMeshProUGUI textMeshPro = transform.Find("gameProgress/gameProgressText").GetComponent<TextMeshProUGUI>();
TextMeshProUGUI textMeshPro = transform.Find("areaGroupList/gameProgress/gameProgressText").GetComponent<TextMeshProUGUI>();
textMeshPro.text = pro.ToString() + "%";
UnityEngine.UI.Slider slider = transform.Find("gameProgress").GetComponent<UnityEngine.UI.Slider>();
UnityEngine.UI.Slider slider = transform.Find("areaGroupList/gameProgress").GetComponent<UnityEngine.UI.Slider>();
slider.value = pro;
}
//点提示,当前组随机一个没涂的位置放大
......@@ -734,7 +729,10 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
else
{
//item = gridViewList.getObjectById(nowidx).GetComponent<colorItem>();
item = gridViewList.GetObjByGID(nowAidByGid).GetComponent<colorItem>();
var item_obj = gridViewList.GetObjByGID(nowAidByGid);
if (item_obj == null)
return;
item = item_obj.GetComponent<colorItem>();
var gdata = groupInfos.FirstOrDefault(a => a.gid == nowAidByGid);
item.NowProgress = gdata.Jindu;
}
......
......@@ -314,12 +314,15 @@ public class gridView : MonoBehaviour
startX = 0 - w / 2 + widthItem / 2 - (widthItem / 2 + interval / 2);
float spacingLen = interval * (size - 1);
float width = coutPixel;
if (width > w)
{
w = width - w;
}
if (w > gameObject.GetComponent<RectTransform>().sizeDelta.x)
rectTransform.sizeDelta = new Vector2(w, rectTransform.sizeDelta.y);
//if (width > w)
//{
// w = width - w;
//}
//if (w > gameObject.GetComponent<RectTransform>().sizeDelta.x)
// rectTransform.sizeDelta = new Vector2(w, rectTransform.sizeDelta.y);
rectTransform.sizeDelta = new Vector2(width - w, rectTransform.sizeDelta.y);
}
utilsTools.setGDataByKey("listViewTempCellSize", new Vector2(widthItem,heightItem));
utilsTools.setGDataByKey("listViewContextCellSize", rectTransform.sizeDelta);
......@@ -351,7 +354,7 @@ public class gridView : MonoBehaviour
if (true == utilsTools.getUserData<string>(itemObject, "scrollViewItemType", out oldItemType, "") && newItemType.Equals(oldItemType))
{
itemObject.transform.GetLocalPositionAndRotation(out vector31, out quaternion);
itemObject.transform.SetLocalPositionAndRotation(vector3, quaternion);
itemObject.transform.SetLocalPositionAndRotation(new Vector3(vector3.x, vector31.y, vector31.z), quaternion);
back(itemObject, i, ListViewBackTypeEnum.update);
if(useVec)
vector3.y = vector3.y + heightItem / 2 + interval / 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment