From 3456c16110a4b341bf0761fdd06c0fc113f6a36b Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Tue, 6 May 2025 15:05:56 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9F=A9=E5=BD=A2?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art/UIPrefab/UIDraw.prefab | 79 +----------------------- Assets/Draw/Scripts/ScreenShotPainter.cs | 75 +++++----------------- Assets/Scenes/Main.unity | 2 +- Assets/Scripts/UI/UIDraw.Designer.cs | 11 ++-- 4 files changed, 24 insertions(+), 143 deletions(-) diff --git a/Assets/Art/UIPrefab/UIDraw.prefab b/Assets/Art/UIPrefab/UIDraw.prefab index abff89c2..5c38d1ea 100644 --- a/Assets/Art/UIPrefab/UIDraw.prefab +++ b/Assets/Art/UIPrefab/UIDraw.prefab @@ -271,81 +271,6 @@ MonoBehaviour: m_hasFontAssetChanged: 0 m_baseMaterial: {fileID: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0} ---- !u!1 &412908320554838416 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 7278440663883465532} - - component: {fileID: 4859354734233530742} - - component: {fileID: 8598899778490155455} - m_Layer: 0 - m_Name: Temp - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &7278440663883465532 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 412908320554838416} - 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: 5248266707218333243} - 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!222 &4859354734233530742 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 412908320554838416} - m_CullTransparentMesh: 1 ---- !u!114 &8598899778490155455 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 412908320554838416} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 0.4117647} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 074cc869ee40c5148b26753fe02c6aec, type: 3} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 --- !u!1 &437928408945815704 GameObject: m_ObjectHideFlags: 0 @@ -381,7 +306,6 @@ RectTransform: - {fileID: 7982209487117141860} - {fileID: 8910459249382205206} - {fileID: 2461520360039377224} - - {fileID: 7278440663883465532} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -401,7 +325,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ec04d319ffe11bf449631785ba9df2ca, type: 3} m_Name: m_EditorClassIdentifier: - mask: {fileID: 2913638650655750658} captureBGImg: {fileID: 1613795782999759057} RawImg: {fileID: 3350589312635769069} Content: {fileID: 6174875567737795578} @@ -436,7 +359,9 @@ MonoBehaviour: CirCleImg: {fileID: 2203796515819680784} RectImg: {fileID: 1594643944354670706} ColorArea: {fileID: 2022575599177353385} + mask: {fileID: 2913638650655750658} colorPicker: {fileID: 3336535175933943458} + TempDraw: {fileID: 0} --- !u!1 &572013391981846340 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Draw/Scripts/ScreenShotPainter.cs b/Assets/Draw/Scripts/ScreenShotPainter.cs index 19cc6bc8..0e7c4921 100644 --- a/Assets/Draw/Scripts/ScreenShotPainter.cs +++ b/Assets/Draw/Scripts/ScreenShotPainter.cs @@ -7,6 +7,7 @@ using UnityEngine.Events; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.UI; +using static UnityEditor.Progress; [RequireComponent(typeof(Camera))] public class ScreenShotPainter : MonoBehaviour @@ -650,11 +651,8 @@ public class ScreenShotPainter : MonoBehaviour break; case Status.Rect: _currentLine = new LineSegment(_paintBrushMat.GetColor("_Color"), _brushSize, _eraserFlag); + Graphics.Blit(_currentRenderTexture, _currentLine.Texture); _lastPoint = Input.mousePosition; - //rectImg.gameObject.SetActive(true); - // TODO: 这样会使UI位置有偏差 后续修改 - //rectImg.transform.position = Input.mousePosition; - isRect = true; break; } } @@ -680,7 +678,9 @@ public class ScreenShotPainter : MonoBehaviour LerpPaint(Input.mousePosition, _eraserFlag); break; case Status.Rect: - + Graphics.Blit(_currentLine.Texture, _currentRenderTexture); + _paintCanvasImg.texture = _currentRenderTexture; + RectFactory(); break; case Status.Circle: var dis = Vector2.Distance(_lastPoint, Input.mousePosition) * 2; @@ -710,14 +710,12 @@ public class ScreenShotPainter : MonoBehaviour if (_currentLine != null) { LerpPaint(Input.mousePosition, false); - FinishedRaw(); } break; case Status.Rect: - isRect = false; - RectFactory(); + FinishedRaw(); break; case Status.Circle: @@ -759,52 +757,6 @@ public class ScreenShotPainter : MonoBehaviour _lastPoint = Vector2.zero; } - bool isRect = false; - private void OnGUI() - { - if (isRect) - { - var points = GenerateRectanglePoints(_lastPoint, Input.mousePosition); - - - float minX = float.MaxValue; - float minY = float.MaxValue; - float maxX = float.MinValue; - float maxY = float.MinValue; - - // 找出最小和最大的 x、y 坐标 - foreach (Vector2 point in points) - { - if (point.x < minX) - { - minX = point.x; - } - if (point.x > maxX) - { - maxX = point.x; - } - if (point.y < minY) - { - minY = point.y; - } - if (point.y > maxY) - { - maxY = point.y; - } - } - - float x = minX; - float y = maxY; - float width = maxX - minX; - float height = maxY - minY; - - Rect rect = new Rect(x, y, width, height); - - GUI.backgroundColor = Color.blue; - GUI.color = Color.yellow; - GUI.Box(rect, "我帮你绘制了个 Rect Box"); - } - } List GenerateCirclePoints(Vector2 center, float r, int numPoints = 36) { @@ -825,14 +777,14 @@ public class ScreenShotPainter : MonoBehaviour { if (_lastPoint != default) { - var points = GenerateRectanglePoints(_lastPoint, Input.mousePosition); + var rectPoints = GenerateRectanglePoints(_lastPoint, Input.mousePosition); - LerpPaint(points[0], false); - LerpPaint(points[1], false); - LerpPaint(points[2], false); - LerpPaint(points[3], false); - LerpPaint(points[0], false); - FinishedRaw(); + LerpPaint(rectPoints[0], false); + LerpPaint(rectPoints[1], false); + LerpPaint(rectPoints[2], false); + LerpPaint(rectPoints[3], false); + LerpPaint(rectPoints[0], false); + //FinishedRaw(); } } @@ -890,6 +842,7 @@ public class ScreenShotPainter : MonoBehaviour _lineStack.Clear(); } + public void Undo() { if (_lineStack.Count > 0) diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 54afac0e..4a98a987 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -372,7 +372,7 @@ MonoBehaviour: m_Bits: 1 m_VolumeTrigger: {fileID: 0} m_VolumeFrameworkUpdateModeOption: 2 - m_RenderPostProcessing: 1 + m_RenderPostProcessing: 0 m_Antialiasing: 0 m_AntialiasingQuality: 2 m_StopNaN: 0 diff --git a/Assets/Scripts/UI/UIDraw.Designer.cs b/Assets/Scripts/UI/UIDraw.Designer.cs index 899d611f..56a5c312 100644 --- a/Assets/Scripts/UI/UIDraw.Designer.cs +++ b/Assets/Scripts/UI/UIDraw.Designer.cs @@ -5,13 +5,11 @@ using QFramework; namespace QFramework.Example { - // Generate Id:c3372197-dece-4bdd-8b25-56df5c08aa5f + // Generate Id:b01e72d6-bd06-47a4-8be3-054bae1344f3 public partial class UIDraw { public const string Name = "UIDraw"; - [SerializeField] - public UnityEngine.UI.Button mask; [SerializeField] public UnityEngine.UI.RawImage captureBGImg; [SerializeField] @@ -81,13 +79,16 @@ namespace QFramework.Example [SerializeField] public UnityEngine.UI.Image ColorArea; [SerializeField] + public UnityEngine.UI.Button mask; + [SerializeField] public UnityEngine.UI.Image colorPicker; + [SerializeField] + public UnityEngine.UI.RawImage TempDraw; private UIDrawData mPrivateData = null; protected override void ClearUIComponents() { - mask = null; captureBGImg = null; RawImg = null; Content = null; @@ -122,7 +123,9 @@ namespace QFramework.Example CirCleImg = null; RectImg = null; ColorArea = null; + mask = null; colorPicker = null; + TempDraw = null; mData = null; } From 5ca2c9ce43056a7475f37fc9d058dd31db1cb080 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Tue, 6 May 2025 16:05:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=8F=8D=E9=A6=88?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art/UIPrefab/UIBody3D.prefab | 156 +++++++++++++- Assets/Art/UIPrefab/UIBody3DInfo.prefab | 8 +- Assets/Art/UIPrefab/UIBody3DMenuTree.prefab | 197 ++++++++++-------- Assets/Art/UIPrefab/UIDraw.prefab | 4 +- .../UIBody3D/左侧工具面板-鼠标 (1).png | Bin 0 -> 1356 bytes .../UIBody3D/左侧工具面板-鼠标 (1).png.meta | 179 ++++++++++++++++ .../UITextures/UIBody3D/左侧工具面板-鼠标.png | Bin 0 -> 1345 bytes .../UIBody3D/左侧工具面板-鼠标.png.meta | 179 ++++++++++++++++ Assets/Scripts/Event/Events.cs | 5 + Assets/Scripts/UI/UIBody3D.cs | 2 + Assets/Scripts/UI/UIBody3DInfo.cs | 32 +-- Assets/Scripts/UI/UIBody3DMenuTree.cs | 31 +-- 12 files changed, 676 insertions(+), 117 deletions(-) create mode 100644 Assets/Art/UITextures/UIBody3D/左侧工具面板-鼠标 (1).png create mode 100644 Assets/Art/UITextures/UIBody3D/左侧工具面板-鼠标 (1).png.meta create mode 100644 Assets/Art/UITextures/UIBody3D/左侧工具面板-鼠标.png create mode 100644 Assets/Art/UITextures/UIBody3D/左侧工具面板-鼠标.png.meta diff --git a/Assets/Art/UIPrefab/UIBody3D.prefab b/Assets/Art/UIPrefab/UIBody3D.prefab index a583df78..7e23c18d 100644 --- a/Assets/Art/UIPrefab/UIBody3D.prefab +++ b/Assets/Art/UIPrefab/UIBody3D.prefab @@ -496,6 +496,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 525842453583727716} - {fileID: 7125848699854436635} m_Father: {fileID: 755010573038241708} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -532,7 +533,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 591c41626b3c40049b45b9c887893684, type: 3} + m_Sprite: {fileID: 21300000, guid: 211b53c2cb3aa6b4cb50f18ae2796465, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -4776,6 +4777,82 @@ MonoBehaviour: m_hasFontAssetChanged: 0 m_baseMaterial: {fileID: 0} m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!1 &3365386694799726991 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 525842453583727716} + - component: {fileID: 7034515135367308003} + - component: {fileID: 2652667528871894338} + m_Layer: 5 + m_Name: High + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &525842453583727716 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3365386694799726991} + 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: 3806297745056633140} + m_Father: {fileID: 3192990638122548755} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 90, y: 42} + m_Pivot: {x: 0, y: 0.5} +--- !u!222 &7034515135367308003 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3365386694799726991} + m_CullTransparentMesh: 1 +--- !u!114 &2652667528871894338 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3365386694799726991} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 2fa24d6664024b342a35c5fb5e7f9843, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 --- !u!1 &3374657125894741702 GameObject: m_ObjectHideFlags: 0 @@ -5607,6 +5684,81 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!1 &4065723111926894133 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3806297745056633140} + - component: {fileID: 3531803610375541400} + - component: {fileID: 9074261777422782138} + m_Layer: 5 + m_Name: Image + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3806297745056633140 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4065723111926894133} + 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: 525842453583727716} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 0, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 52, y: 52} + m_Pivot: {x: 0, y: 0.49999997} +--- !u!222 &3531803610375541400 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4065723111926894133} + m_CullTransparentMesh: 1 +--- !u!114 &9074261777422782138 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4065723111926894133} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: 40821b66a31d1fc40a15b6f434e487f9, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 --- !u!1 &4076795204144826265 GameObject: m_ObjectHideFlags: 0 @@ -8959,7 +9111,7 @@ MonoBehaviour: onValueChanged: m_PersistentCalls: m_Calls: [] - m_IsOn: 1 + m_IsOn: 0 --- !u!1 &6676211856046294148 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Art/UIPrefab/UIBody3DInfo.prefab b/Assets/Art/UIPrefab/UIBody3DInfo.prefab index db676c4c..3ad3670f 100644 --- a/Assets/Art/UIPrefab/UIBody3DInfo.prefab +++ b/Assets/Art/UIPrefab/UIBody3DInfo.prefab @@ -73,7 +73,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} m_AnchoredPosition: {x: 0, y: -22} - m_SizeDelta: {x: 54.01, y: 34} + m_SizeDelta: {x: 0, y: 34} m_Pivot: {x: 0, y: 0.5} --- !u!222 &5612155728787226803 CanvasRenderer: @@ -4447,9 +4447,9 @@ RectTransform: - {fileID: 4460888939854281799} m_Father: {fileID: 9173910592677138117} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 59.01, y: -22} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 34} m_Pivot: {x: 0.00000007636845, y: 0.5} --- !u!1 &8390197820936015822 diff --git a/Assets/Art/UIPrefab/UIBody3DMenuTree.prefab b/Assets/Art/UIPrefab/UIBody3DMenuTree.prefab index 2d72775d..f78de67a 100644 --- a/Assets/Art/UIPrefab/UIBody3DMenuTree.prefab +++ b/Assets/Art/UIPrefab/UIBody3DMenuTree.prefab @@ -1,80 +1,5 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!1 &435568366843394627 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 7503212725544534556} - - component: {fileID: 111412417819572624} - - component: {fileID: 2151844151933240927} - m_Layer: 0 - m_Name: temp - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &7503212725544534556 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 435568366843394627} - 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: 8239230575637970371} - 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!222 &111412417819572624 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 435568366843394627} - m_CullTransparentMesh: 1 ---- !u!114 &2151844151933240927 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 435568366843394627} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 0.8156863} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 79c08d6abbc3e5b4d93756d5972f8459, type: 3} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 --- !u!1 &438363884195299804 GameObject: m_ObjectHideFlags: 0 @@ -1028,11 +953,11 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 8239230575637970371} + m_Father: {fileID: 2780512865034176281} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 712, y: 374.04} + m_AnchoredPosition: {x: -3, y: 374.04} m_SizeDelta: {x: 32, y: 2} m_Pivot: {x: 0, y: 0.5} --- !u!222 &1285110849480394043 @@ -1275,11 +1200,11 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 8239230575637970371} + m_Father: {fileID: 2780512865034176281} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 659.93, y: 372.56} + m_AnchoredPosition: {x: -55.070007, y: 372.56} m_SizeDelta: {x: 260, y: 1} m_Pivot: {x: 0, y: 0.5} --- !u!222 &3335622323102402595 @@ -1484,10 +1409,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 2780512865034176281} - - {fileID: 5296772743380432635} - - {fileID: 2058219366310914181} - {fileID: 2765956842469010051} - - {fileID: 7503212725544534556} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} @@ -2647,6 +2569,7 @@ GameObject: m_Component: - component: {fileID: 2780512865034176281} - component: {fileID: 1546129111403102217} + - component: {fileID: 4641075730446385994} m_Layer: 0 m_Name: RootContent m_TagString: Untagged @@ -2670,6 +2593,8 @@ RectTransform: - {fileID: 348112869011454683} - {fileID: 1108598377964087841} - {fileID: 2362316407852543289} + - {fileID: 5296772743380432635} + - {fileID: 2058219366310914181} m_Father: {fileID: 8239230575637970371} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0.5} @@ -2693,6 +2618,114 @@ MonoBehaviour: CustomComponentName: RootContent CustomComment: mComponentName: RectTransform +--- !u!114 &4641075730446385994 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8197937570590596469} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4d0390bd8b8ffd640b34fe25065ff1df, type: 3} + m_Name: + m_EditorClassIdentifier: + updateType: 0 + isSpeedBased: 0 + hasOnStart: 0 + hasOnPlay: 0 + hasOnUpdate: 0 + hasOnStepComplete: 0 + hasOnComplete: 0 + hasOnTweenCreated: 0 + hasOnRewind: 0 + onStart: + m_PersistentCalls: + m_Calls: [] + onPlay: + m_PersistentCalls: + m_Calls: [] + onUpdate: + m_PersistentCalls: + m_Calls: [] + onStepComplete: + m_PersistentCalls: + m_Calls: [] + onComplete: + m_PersistentCalls: + m_Calls: [] + onTweenCreated: + m_PersistentCalls: + m_Calls: [] + onRewind: + m_PersistentCalls: + m_Calls: [] + targetIsSelf: 1 + targetGO: {fileID: 0} + tweenTargetIsTargetGO: 1 + delay: 0 + duration: 0.3 + easeType: 12 + easeCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + loopType: 0 + loops: 1 + id: + isRelative: 0 + isFrom: 0 + isIndependentUpdate: 0 + autoKill: 0 + autoGenerate: 1 + isActive: 1 + isValid: 1 + target: {fileID: 2780512865034176281} + animationType: 1 + targetType: 5 + forcedTargetType: 0 + autoPlay: 0 + useTargetAsV3: 0 + endValueFloat: 0 + endValueV3: {x: 450, y: 0, z: 0} + endValueV2: {x: 0, y: 0} + endValueColor: {r: 1, g: 1, b: 1, a: 1} + endValueString: + endValueRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 0 + height: 0 + endValueTransform: {fileID: 0} + optionalBool0: 0 + optionalBool1: 0 + optionalFloat0: 0 + optionalInt0: 0 + optionalRotationMode: 0 + optionalScrambleMode: 0 + optionalShakeRandomnessMode: 0 + optionalString: --- !u!1 &8280112074671649668 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Art/UIPrefab/UIDraw.prefab b/Assets/Art/UIPrefab/UIDraw.prefab index 5c38d1ea..c925c0e1 100644 --- a/Assets/Art/UIPrefab/UIDraw.prefab +++ b/Assets/Art/UIPrefab/UIDraw.prefab @@ -7670,7 +7670,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8470605304935464912} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Name: @@ -7748,7 +7748,7 @@ MonoBehaviour: m_PressedTrigger: Pressed m_SelectedTrigger: Selected m_DisabledTrigger: Disabled - m_Interactable: 1 + m_Interactable: 0 m_TargetGraphic: {fileID: 8708082608090175244} toggleTransition: 1 graphic: {fileID: 1510141012094268438} diff --git a/Assets/Art/UITextures/UIBody3D/左侧工具面板-鼠标 (1).png b/Assets/Art/UITextures/UIBody3D/左侧工具面板-鼠标 (1).png new file mode 100644 index 0000000000000000000000000000000000000000..4390721ba32a5ebfa3c7d5d5f67f3e1bca0cee5d GIT binary patch literal 1356 zcmV-S1+)5zP)Px)21!IgRA@u(m|sj=Wf;bvuhgZmu@x`@kwJ%MjLu|-$O2On+RPY6GHJc^#&T^G zdf}oH2TbCv^vdWB)Vq0MhZkd$ErsbKe_~q9gasC8#{Ol1JzWPaqdlL#M@mWs*`Ym! zke;MT|9szfp5Obt-*di{VUJyGkMSS_wA&rcIFxZH%@xSBT$&56_;wkG6qhW`6EY5^ zx!{U#mllUAYtFQgvWeloF2xEJPEZ}lSliGJ&f8>NoOO(kTy9sWQPFT!f!4vqWT_0L z8c+;|aVB!c^~AIGUPUNXfQ+^EHgMK018|t3;U3u_iB&NMHvuxnZGR43aVqMk=NPOG z(8&e?8r}_wHI0v6_8M!>aMCh9+{cWoze$W+Zx3DZJ%>g`LsS7uR1goONZmFDrweFi z)uAKX(5PriN`Pq3NWj2mEo3m6!O*%OaTxNBv*bl)mFdvtw<5;)M)?agNF??0=*>77wbl7D0f1uo@Y|{#lx^yd#;qiFT)6;`)F@dVM^+Y7hbEiXml z$(6(_KR;je`~5Ehh$_*T6i|Xw8^t!uEhw&7UKHOiDK7f(`t|Gi1l7^evDRMkVlQ2~ z1dGKYe?@KRa5&xo@LO7e=w`=G*4s4DcoSoLRftAkTzul`{9o^umK1*+gNhePE}2Xw z*)3{0f}u9-?Cg9m8jZTr4z$G$S!u=VGl7MNIf3~Hw*)~jQ@fFHpU)@1=yEt5=Re&Ri=}q-kojzpkyVtt*yfiQ;JAQ2G%d!I3)zO6_O2+rI+Py7NG^ zr!=gaa~^m!d;45C=>PVe(^hzaB%Q@0L1`)1n|wS0E&m=QWVk13YNo*@IRjI zf3on9m6w-SpFMk4PXIC3sQs)~t52)deh`U7xK5|L9}b77cMZ_G=M;UAA{SiIlZuboU^gqK-075i_{`}fiKqRKJrlFZ0_!Gld9joHB z01oPOI(;M(IV?$%O_HQL0EPgJ0a#E95`#|qq@bjFn~c=~sGy@9fcpR<$*j2>fRfSw zpSc;Jl$KM4#WD`5P}GzznQPx(`$c7hLVkBW~?M8 zi;yYo1K^l=Ve>izZUaFv+!u72MK%b^Z7?U`4HYvhj$0-mjz*xgkge-G&YQPODd6no zt(EkAfu`>{@AG^9&+|V|2^QHRi;M?0AZu6DrjSh`3unMqau!aw!LPF^WN^wXyuqfB zg%fV@>nx%W!!XG-GD1j>!4Vp`fp;K=VfFyn&Be8s5JErmws-~7gV93p3dI|c4$K$; z5l5r_pEoF8fEb3604M@L0U`i&azFt9nmIrTA*96IwZ|9GdJZUo5ORZ=k&810!Z3{X zyG?|U{$~P6KS*65a|7s~$BRPq0QGSSc|8+AT+jTxPzf;%!>BP1|ftt{j9~ogmVT#pP2*2Fbp*f+FK^OpGiP^)*L|%K$nKgyw=s|SJVWk89eSe zlc0= z98In5@bO-Soyi}=$;p9kilRjQsuWd_!hg2+Xx5!8=Q9npd82`z1WG281-4$i zB&}<{;{NrK-B|AGg0jjgG`6;(IPVY}YgJ7HV&0CL6L;tv?~k=LeD4h4A48x_0@8z; z&$dZ)bhJ&@4OV0SXA{0h#3$dK}Q2pf@8oMuarP$8Eyk@B=iqwj)@)mQ_Kan8YV(S@`BqCUOhQ5y_R? z|QV8!iAnWc! z0&g=<~i_*+9D+49~jhtu9abRUJQ{poC} z;CZ3jqd)JToqY80xK#k@La9_LjE;_?ySp0|-<_#%`t>UD_I)`pGW<1Bka+EXs!`ic z{B&1;&#jh^)M_;&5C{gRr>A?Z21xIof=Z>@=j`l!Vrpv2&)(kNQ}lxSdI#ZB-@xF| zD50anbYo*f>&VdElE0M7Y5-FJG;}DjDj*JO2mMP3ImQL|8~~v}AP}k5>J=|~_({g( zL%*xW().DORestart(); RightBottom.GetComponent().DORestart(); HideAll.transform.Find("Label").GetComponent().text = "ʾ"; + TypeEventSystem.Global.Send(new OnHideAll() { isHide = true }); } else { @@ -143,6 +144,7 @@ namespace QFramework.Example RightContent.GetComponent().DOPlayBackwards(); RightBottom.GetComponent().DOPlayBackwards(); HideAll.transform.Find("Label").GetComponent().text = ""; + TypeEventSystem.Global.Send(new OnHideAll() { isHide = false }); } CloseBtn.gameObject.SetActive(!isOn); diff --git a/Assets/Scripts/UI/UIBody3DInfo.cs b/Assets/Scripts/UI/UIBody3DInfo.cs index a8648681..7666d81f 100644 --- a/Assets/Scripts/UI/UIBody3DInfo.cs +++ b/Assets/Scripts/UI/UIBody3DInfo.cs @@ -36,18 +36,7 @@ namespace QFramework.Example } }); - Active.onValueChanged.AddListener(isOn => - { - obj.SetActive(isOn); - if (isOn) - { - Active.transform.Find("Label").GetComponent().text = ""; - } - else - { - Active.transform.Find("Label").GetComponent().text = "ʾ"; - } - }); + Transparent.onValueChanged.AddListener(isOn => { @@ -167,6 +156,25 @@ namespace QFramework.Example obj = Utility.FindObj(mData.body.Path); Des.text = mData.body.Tip; RefreshTipPath(); + + Active.onValueChanged.RemoveAllListeners(); + Active.isOn = false; + Active.transform.Find("Label").GetComponent().text = ""; + Active.onValueChanged.AddListener(isOn => + { + obj.SetActive(!isOn); + if (isOn) + { + Body3DController.Instance.AddActiveObj(obj); + Active.transform.Find("Label").GetComponent().text = "ʾ"; + } + else + { + Body3DController.Instance.PopActiveObj(); + Active.transform.Find("Label").GetComponent().text = ""; + } + }); + } public void ListItemFacotry(Body3D.Body body) diff --git a/Assets/Scripts/UI/UIBody3DMenuTree.cs b/Assets/Scripts/UI/UIBody3DMenuTree.cs index 4a513713..1734f6e9 100644 --- a/Assets/Scripts/UI/UIBody3DMenuTree.cs +++ b/Assets/Scripts/UI/UIBody3DMenuTree.cs @@ -201,12 +201,13 @@ namespace QFramework.Example Half, Full } - //DOTweenAnimation contentAnim; + DOTweenAnimation contentAnim; protected override void OnInit(IUIData uiData = null) { mData = uiData as UIBody3DMenuTreeData ?? new UIBody3DMenuTreeData(); TypeEventSystem.Global.Register(OnModuleQuithandler).UnRegisterWhenGameObjectDestroyed(this); - //contentAnim = RootContent.GetComponent(); + TypeEventSystem.Global.Register(OnHideAllhandler); + contentAnim = RootContent.GetComponent(); // please add init code here Close.onClick.AddListener(() => { @@ -236,6 +237,18 @@ namespace QFramework.Example BuildTreeUI(mData.body); } + private void OnHideAllhandler(OnHideAll all) + { + if (all.isHide) + { + contentAnim.DOPlayForward(); + } + else + { + contentAnim.DOPlayBackwards(); + } + } + private void OnModuleQuithandler(OnModuleQuit quit) { Hide(); @@ -398,19 +411,7 @@ namespace QFramework.Example protected override void OnShow() { } - //public override void Hide() - //{ - // //if (contentAnim.onComplete == null) - // //{ - // // contentAnim.onComplete = new UnityEngine.Events.UnityEvent(); - // //} - // //contentAnim.onComplete.RemoveAllListeners(); - // //contentAnim.DOPlayBackwards(); - // //contentAnim.onComplete.AddListener(() => - // //{ - // // base.Hide(); - // //}); - //} + protected override void OnHide() { From d95f71b5e3bd87952cc2cb1e7faeb69b2d74b344 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Tue, 6 May 2025 16:37:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=BB=E7=BA=BF?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Draw/Scripts/ScreenShotPainter.cs | 26 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Assets/Draw/Scripts/ScreenShotPainter.cs b/Assets/Draw/Scripts/ScreenShotPainter.cs index 0e7c4921..69da6734 100644 --- a/Assets/Draw/Scripts/ScreenShotPainter.cs +++ b/Assets/Draw/Scripts/ScreenShotPainter.cs @@ -7,7 +7,6 @@ using UnityEngine.Events; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.UI; -using static UnityEditor.Progress; [RequireComponent(typeof(Camera))] public class ScreenShotPainter : MonoBehaviour @@ -621,6 +620,7 @@ public class ScreenShotPainter : MonoBehaviour ChangeToEraser(this.status == Status.Eraser); } + Vector2 lineStart = Vector2.zero; private void OnPaintBeginDrag(BaseEventData arg0) { if (_enabled && _haveRegion) @@ -631,15 +631,15 @@ public class ScreenShotPainter : MonoBehaviour break; case Status.Line: - if (Input.GetMouseButton(0)) + if (_currentLine == null) { - if (_currentLine == null) - { - _currentLine = new LineSegment(_paintBrushMat.GetColor("_Color"), _brushSize, _eraserFlag); - } - LerpPaint(Input.mousePosition, _eraserFlag); + _currentLine = new LineSegment(_paintBrushMat.GetColor("_Color"), _brushSize, _eraserFlag); + Graphics.Blit(_currentRenderTexture, _currentLine.Texture); } + lineStart = Input.mousePosition; + _lastPoint = lineStart; + break; case Status.Circle: @@ -677,6 +677,16 @@ public class ScreenShotPainter : MonoBehaviour } LerpPaint(Input.mousePosition, _eraserFlag); break; + case Status.Line: + if (_lastPoint != default && Vector2.Distance(lineStart, Input.mousePosition) > 2f) + { + Graphics.Blit(_currentLine.Texture, _currentRenderTexture); + _paintCanvasImg.texture = _currentRenderTexture; + _lastPoint = lineStart; + Paint(_eraserFlag, lineStart); + LerpPaint(Input.mousePosition, _eraserFlag); + } + break; case Status.Rect: Graphics.Blit(_currentLine.Texture, _currentRenderTexture); _paintCanvasImg.texture = _currentRenderTexture; @@ -709,8 +719,8 @@ public class ScreenShotPainter : MonoBehaviour case Status.Line: if (_currentLine != null) { - LerpPaint(Input.mousePosition, false); FinishedRaw(); + lineStart = Vector2.zero; } break; From 5c9b489242f146a72c6b39bc3225ee69ac6dc0b3 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Tue, 6 May 2025 17:22:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=AE=AD=E5=A4=B4?= =?UTF-8?q?=E7=BB=98=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art/UIPrefab/UIDraw.prefab | 4 +- Assets/Draw/Scripts/ScreenShotPainter.cs | 60 +++++++++++++++++++++++- Assets/Scripts/UI/UIDraw.cs | 9 ++++ 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/Assets/Art/UIPrefab/UIDraw.prefab b/Assets/Art/UIPrefab/UIDraw.prefab index c925c0e1..5c38d1ea 100644 --- a/Assets/Art/UIPrefab/UIDraw.prefab +++ b/Assets/Art/UIPrefab/UIDraw.prefab @@ -7670,7 +7670,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8470605304935464912} - m_Enabled: 0 + m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Name: @@ -7748,7 +7748,7 @@ MonoBehaviour: m_PressedTrigger: Pressed m_SelectedTrigger: Selected m_DisabledTrigger: Disabled - m_Interactable: 0 + m_Interactable: 1 m_TargetGraphic: {fileID: 8708082608090175244} toggleTransition: 1 graphic: {fileID: 1510141012094268438} diff --git a/Assets/Draw/Scripts/ScreenShotPainter.cs b/Assets/Draw/Scripts/ScreenShotPainter.cs index 69da6734..971cfe88 100644 --- a/Assets/Draw/Scripts/ScreenShotPainter.cs +++ b/Assets/Draw/Scripts/ScreenShotPainter.cs @@ -213,6 +213,7 @@ public class ScreenShotPainter : MonoBehaviour Line, Rect, Circle, + Arrow, } public EnterCaptureModeEvent EnterCaptureModeEvent { @@ -654,6 +655,12 @@ public class ScreenShotPainter : MonoBehaviour Graphics.Blit(_currentRenderTexture, _currentLine.Texture); _lastPoint = Input.mousePosition; break; + case Status.Arrow: + _currentLine = new LineSegment(_paintBrushMat.GetColor("_Color"), _brushSize, _eraserFlag); + Graphics.Blit(_currentRenderTexture, _currentLine.Texture); + lineStart = Input.mousePosition; + _lastPoint = lineStart; + break; } } } @@ -696,6 +703,11 @@ public class ScreenShotPainter : MonoBehaviour var dis = Vector2.Distance(_lastPoint, Input.mousePosition) * 2; circleImg.rectTransform.sizeDelta = new Vector2(dis, dis); break; + case Status.Arrow: + Graphics.Blit(_currentLine.Texture, _currentRenderTexture); + _paintCanvasImg.texture = _currentRenderTexture; + ArrowFactory(); + break; } } @@ -725,7 +737,8 @@ public class ScreenShotPainter : MonoBehaviour break; case Status.Rect: - FinishedRaw(); + if (_currentLine != null) + FinishedRaw(); break; case Status.Circle: @@ -746,6 +759,13 @@ public class ScreenShotPainter : MonoBehaviour } break; + case Status.Arrow: + if (_currentLine != null) + { + FinishedRaw(); + lineStart = Vector2.zero; + } + break; default: break; } @@ -797,6 +817,19 @@ public class ScreenShotPainter : MonoBehaviour //FinishedRaw(); } } + public void ArrowFactory() + { + if (lineStart != default) + { + var points = GenerateArrowPoints(lineStart, Input.mousePosition,0.1f); + _lastPoint = lineStart; + Paint(_eraserFlag, lineStart); + LerpPaint(Input.mousePosition, _eraserFlag); + LerpPaint(points[1], false); + _lastPoint = Input.mousePosition; + LerpPaint(points[3], false); + } + } public Vector2[] GenerateRectanglePoints(Vector2 start, Vector2 thirdPoint) { @@ -840,6 +873,31 @@ public class ScreenShotPainter : MonoBehaviour } + + public Vector2[] GenerateArrowPoints(Vector2 start, Vector2 end, float arrowWidth = 0.3f, float arrowHeadLength = 0.2f) + { + Vector2[] points = new Vector2[4]; + + // 计算方向向量 + Vector2 direction = end - start; + float length = direction.magnitude; + Vector2 normalizedDir = direction.normalized; + + // 计算箭头头部的基准点(箭头左右两侧点所在的位置) + Vector2 arrowBase = end - normalizedDir * length * arrowHeadLength; + + // 计算垂直于方向的向量(用于确定箭头宽度) + Vector2 perpendicular = new Vector2(-normalizedDir.y, normalizedDir.x) * length * arrowWidth; + + // 箭头四个点的位置 + points[0] = start; // 箭尾 + points[1] = arrowBase - perpendicular; // 箭头左侧点 + points[2] = end; // 箭头顶点 + points[3] = arrowBase + perpendicular; // 箭头右侧点 + + return points; + } + public void Clear() { // 重新分配 RenderTexture diff --git a/Assets/Scripts/UI/UIDraw.cs b/Assets/Scripts/UI/UIDraw.cs index 160c1d15..41e13012 100644 --- a/Assets/Scripts/UI/UIDraw.cs +++ b/Assets/Scripts/UI/UIDraw.cs @@ -124,6 +124,15 @@ namespace QFramework.Example } }); + + Arrow.onValueChanged.AddListener(isOn => + { + if (isOn) + { + ScreenShotPainter.instance.SetStatus(ScreenShotPainter.Status.Arrow); + } + }); + ColorAreaBtn.onClick.AddListener(() => { ColorArea.gameObject.SetActive(true);