Signed-off-by: XgC2961 <2961904938@qq.com>
This commit is contained in:
parent
bd0b186de3
commit
839fbcdc84
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -7,7 +7,7 @@
|
|||
"RelativeMoniker": "D:0:0:{145CD178-D4F7-B17C-8038-BA27BF626D94}|Assembly-CSharp.csproj|solutionrelative:assets\\scrip\\rotateandscale.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{145CD178-D4F7-B17C-8038-BA27BF626D94}|Assembly-CSharp.csproj|d:\\unity\\projects\\new\\specialequipment\\assets\\scrip\\uifunction.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"AbsoluteMoniker": "D:0:0:{145CD178-D4F7-B17C-8038-BA27BF626D94}|Assembly-CSharp.csproj|D:\\Unity\\Projects\\new\\SpecialEquipment\\assets\\scrip\\uifunction.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{145CD178-D4F7-B17C-8038-BA27BF626D94}|Assembly-CSharp.csproj|solutionrelative:assets\\scrip\\uifunction.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
"RelativeDocumentMoniker": "Assets\\scrip\\RotateAndScale.cs",
|
||||
"ToolTip": "D:\\Unity\\Projects\\new\\SpecialEquipment\\Assets\\scrip\\RotateAndScale.cs",
|
||||
"RelativeToolTip": "Assets\\scrip\\RotateAndScale.cs",
|
||||
"ViewState": "AgIAACEAAAAAAAAAAAAAABwAAAAkAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAoAAAAiAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-08-19T06:33:22.973Z",
|
||||
"EditorCaption": ""
|
||||
|
|
@ -98,8 +98,7 @@
|
|||
"RelativeToolTip": "Assets\\scrip\\UIFunction.cs",
|
||||
"ViewState": "AgIAAJ0AAAAAAAAAAABCwLIAAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-08-18T09:00:50.275Z",
|
||||
"EditorCaption": ""
|
||||
"WhenOpened": "2025-08-18T09:00:50.275Z"
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
"RelativeDocumentMoniker": "Assets\\scrip\\RotateAndScale.cs",
|
||||
"ToolTip": "D:\\Unity\\Projects\\new\\SpecialEquipment\\Assets\\scrip\\RotateAndScale.cs",
|
||||
"RelativeToolTip": "Assets\\scrip\\RotateAndScale.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAoAAAAiAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAB4AAAAAAAAAAAAqwDIAAAAfAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-08-19T06:33:22.973Z",
|
||||
"EditorCaption": ""
|
||||
|
|
|
|||
|
|
@ -5,12 +5,11 @@ public class RotateAndScale : MonoBehaviour
|
|||
[Header("ÐýתÉèÖÃ")]
|
||||
public float rotationSpeed = 0.2f; // ÐýתËÙ¶È
|
||||
private bool isRotating = false;
|
||||
private float lastMouseX;
|
||||
private Vector3 lastMousePos;
|
||||
|
||||
[Header("ÍÏ×§ÉèÖÃ")]
|
||||
public float dragSpeed = 0.1f;
|
||||
public float dragSpeed = 0.01f;
|
||||
private bool isDragging = false;
|
||||
private float lastMouseY;
|
||||
|
||||
[Header("Ëõ·ÅÉèÖÃ")]
|
||||
public float scaleSpeed = 0.5f; // Ëõ·ÅËÙ¶È
|
||||
|
|
@ -23,12 +22,19 @@ public class RotateAndScale : MonoBehaviour
|
|||
HandleScaling();
|
||||
}
|
||||
|
||||
// 页面重新进入时调用,重置输入状态
|
||||
public void ResetInput()
|
||||
{
|
||||
isRotating = false;
|
||||
isDragging = false;
|
||||
}
|
||||
|
||||
private void HandleRotation()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
isRotating = true;
|
||||
lastMouseX = Input.mousePosition.x;
|
||||
lastMousePos = Input.mousePosition;
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
|
|
@ -38,9 +44,16 @@ public class RotateAndScale : MonoBehaviour
|
|||
|
||||
if (isRotating)
|
||||
{
|
||||
float deltaX = Input.mousePosition.x - lastMouseX;
|
||||
transform.Rotate(0f, -deltaX * rotationSpeed, 0f, Space.World);
|
||||
lastMouseX = Input.mousePosition.x;
|
||||
Vector3 delta = Input.mousePosition - lastMousePos;
|
||||
|
||||
// 根据鼠标移动旋转:横向控制 Y 轴,纵向控制 X 轴
|
||||
float rotationX = delta.y * rotationSpeed;
|
||||
float rotationY = -delta.x * rotationSpeed;
|
||||
|
||||
transform.Rotate(Vector3.up, rotationY, Space.World);
|
||||
transform.Rotate(Vector3.right, rotationX, Space.World);
|
||||
|
||||
lastMousePos = Input.mousePosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,8 +62,7 @@ public class RotateAndScale : MonoBehaviour
|
|||
if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
isDragging = true;
|
||||
lastMouseX = Input.mousePosition.x;
|
||||
lastMouseY = Input.mousePosition.y;
|
||||
lastMousePos = Input.mousePosition;
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonUp(1))
|
||||
|
|
@ -60,13 +72,9 @@ public class RotateAndScale : MonoBehaviour
|
|||
|
||||
if (isDragging)
|
||||
{
|
||||
float deltaX = Input.mousePosition.x - lastMouseX;
|
||||
float deltaY = Input.mousePosition.y - lastMouseY;
|
||||
|
||||
transform.Translate(new Vector3(deltaX, deltaY, 0f) * dragSpeed, Space.World);
|
||||
|
||||
lastMouseX = Input.mousePosition.x;
|
||||
lastMouseY = Input.mousePosition.y;
|
||||
Vector3 delta = Input.mousePosition - lastMousePos;
|
||||
transform.Translate(new Vector3(delta.x, delta.y, 0) * dragSpeed, Space.World);
|
||||
lastMousePos = Input.mousePosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,15 +90,4 @@ public class RotateAndScale : MonoBehaviour
|
|||
transform.localScale = newScale;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在返回并重新选择物体时调用,重置输入状态
|
||||
/// </summary>
|
||||
public void ResetInputState()
|
||||
{
|
||||
isRotating = false;
|
||||
isDragging = false;
|
||||
lastMouseX = Input.mousePosition.x;
|
||||
lastMouseY = Input.mousePosition.y;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -121,7 +121,7 @@ MonoBehaviour:
|
|||
m_MinSize: {x: 400, y: 200}
|
||||
m_MaxSize: {x: 32384, y: 16192}
|
||||
vertical: 0
|
||||
controlID: 52
|
||||
controlID: 72
|
||||
--- !u!114 &6
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
|
|
@ -172,7 +172,7 @@ MonoBehaviour:
|
|||
m_MinSize: {x: 100, y: 200}
|
||||
m_MaxSize: {x: 8096, y: 16192}
|
||||
vertical: 1
|
||||
controlID: 53
|
||||
controlID: 73
|
||||
--- !u!114 &8
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
|
|
@ -249,7 +249,7 @@ MonoBehaviour:
|
|||
m_MinSize: {x: 100, y: 200}
|
||||
m_MaxSize: {x: 8096, y: 16192}
|
||||
vertical: 1
|
||||
controlID: 15
|
||||
controlID: 104
|
||||
--- !u!114 &11
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
|
|
@ -453,9 +453,9 @@ MonoBehaviour:
|
|||
m_SceneHierarchy:
|
||||
m_TreeViewState:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs: 6a2cffff
|
||||
m_LastClickedID: -54166
|
||||
m_ExpandedIDs: 34fbffffc4570000dc570000ee580000f85800004e59000098590000fc5900003e5a0000525a0000cc5a0000f05a00007c5b0000a85b0000f65b0000b85c0000bc5c00001c5d0000505d0000
|
||||
m_SelectedIDs: 3c580000
|
||||
m_LastClickedID: 22588
|
||||
m_ExpandedIDs: 34fbfffff8580000fc590000bc5c0000
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
|
|
@ -975,7 +975,7 @@ MonoBehaviour:
|
|||
m_SkipHidden: 0
|
||||
m_SearchArea: 1
|
||||
m_Folders:
|
||||
- Assets/Prefab
|
||||
- Assets/scrip
|
||||
m_Globs: []
|
||||
m_OriginalText:
|
||||
m_FilterByTypeIntersection: 0
|
||||
|
|
@ -990,7 +990,7 @@ MonoBehaviour:
|
|||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs: 08750000
|
||||
m_LastClickedID: 29960
|
||||
m_ExpandedIDs: 000000005c5e000012ce010014ce010016ce010018ce0100
|
||||
m_ExpandedIDs: 00000000605e000012ce010014ce0100
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
|
|
@ -1015,10 +1015,10 @@ MonoBehaviour:
|
|||
m_Icon: {fileID: 0}
|
||||
m_ResourceFile:
|
||||
m_AssetTreeState:
|
||||
scrollPos: {x: 0, y: 1.8000183}
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs:
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: ffffffff000000005c5e000012ce010016ce0100
|
||||
m_ExpandedIDs: ffffffff00000000605e000012ce010014ce0100
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
|
|
|
|||
Loading…
Reference in New Issue