diff --git a/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset b/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset index 360a264bb..eac6aa9fe 100644 --- a/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset +++ b/Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset @@ -612,7 +612,7 @@ MonoBehaviour: sourceProjectPath: sourceBankPath: Assets/FMOD Banks/Desktop sourceBankPathUnformatted: - BankRefreshCooldown: 5 + BankRefreshCooldown: -2 ShowBankRefreshWindow: 1 AutomaticEventLoading: 1 BankLoadType: 0 diff --git a/Assets/Scenes/CutTest.unity b/Assets/Scenes/CutTest.unity index e0b67030e..aac5a78cb 100644 --- a/Assets/Scenes/CutTest.unity +++ b/Assets/Scenes/CutTest.unity @@ -195,7 +195,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 4 + m_SortingOrder: 10 m_Sprite: {fileID: -50090516736836665, guid: 2338fddc038248b4b934bef72357cd13, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -634,7 +634,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 2 + m_SortingOrder: 9 m_Sprite: {fileID: 3822937466802405960, guid: fd04c28739017964789d58d573f9fabb, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -1316,7 +1316,6 @@ GameObject: - component: {fileID: 1568743344} - component: {fileID: 1568743343} - component: {fileID: 1568743345} - - component: {fileID: 1568743346} m_Layer: 0 m_Name: "\u523B\u5F55\u9F7F\u8F6E" m_TagString: Untagged @@ -1364,7 +1363,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 1 + m_SortingOrder: 5 m_Sprite: {fileID: -940084629, guid: bafdc649320f43648818df231a45ad8f, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -1408,113 +1407,10 @@ MonoBehaviour: snapDistance: 0.3 detachDistance: 10 tractionSpeed: 1 - cutLineRenderer: {fileID: 1568743346} + edgePointsScale: 1.2 + cutLineRenderer: {fileID: 2135342731} cutLineWidth: 0.1 noiseAmount: 0.05 ---- !u!120 &1568743346 -LineRenderer: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1568743342} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 0 - m_LightProbeUsage: 0 - m_ReflectionProbeUsage: 0 - m_RayTracingMode: 0 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_Positions: - - {x: 0, y: 0, z: 0} - - {x: 0, y: 0, z: 1} - m_Parameters: - serializedVersion: 3 - widthMultiplier: 1 - widthCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - colorGradient: - serializedVersion: 2 - key0: {r: 1, g: 1, b: 1, a: 1} - key1: {r: 1, g: 1, b: 1, a: 1} - key2: {r: 0, g: 0, b: 0, a: 0} - key3: {r: 0, g: 0, b: 0, a: 0} - key4: {r: 0, g: 0, b: 0, a: 0} - key5: {r: 0, g: 0, b: 0, a: 0} - key6: {r: 0, g: 0, b: 0, a: 0} - key7: {r: 0, g: 0, b: 0, a: 0} - ctime0: 0 - ctime1: 65535 - ctime2: 0 - ctime3: 0 - ctime4: 0 - ctime5: 0 - ctime6: 0 - ctime7: 0 - atime0: 0 - atime1: 65535 - atime2: 0 - atime3: 0 - atime4: 0 - atime5: 0 - atime6: 0 - atime7: 0 - m_Mode: 0 - m_ColorSpace: -1 - m_NumColorKeys: 2 - m_NumAlphaKeys: 2 - numCornerVertices: 0 - numCapVertices: 0 - alignment: 0 - textureMode: 0 - textureScale: {x: 1, y: 1} - shadowBias: 0.5 - generateLightingData: 0 - m_MaskInteraction: 0 - m_UseWorldSpace: 1 - m_Loop: 0 - m_ApplyActiveColorSpace: 1 --- !u!1 &1598025874 GameObject: m_ObjectHideFlags: 0 @@ -1574,7 +1470,7 @@ SpriteRenderer: m_SortingLayer: 0 m_SortingOrder: 0 m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3} - m_Color: {r: 0, g: 0, b: 0, a: 1} + m_Color: {r: 0.26415092, g: 0.26415092, b: 0.26415092, a: 1} m_FlipX: 0 m_FlipY: 0 m_DrawMode: 0 @@ -1716,7 +1612,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 3 + m_SortingOrder: 8 m_Sprite: {fileID: -1886049787586984079, guid: 2338fddc038248b4b934bef72357cd13, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -1820,6 +1716,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2135342730} + - component: {fileID: 2135342731} m_Layer: 0 m_Name: GameObject m_TagString: Untagged @@ -1842,6 +1739,110 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!120 &2135342731 +LineRenderer: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2135342729} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 0 + m_LightProbeUsage: 0 + m_ReflectionProbeUsage: 0 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Positions: + - {x: 0, y: 0, z: 0} + - {x: 0, y: 0, z: 1} + m_Parameters: + serializedVersion: 3 + widthMultiplier: 1 + widthCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + colorGradient: + serializedVersion: 2 + key0: {r: 0, g: 0, b: 0, a: 1} + key1: {r: 0, g: 0, b: 0, a: 1} + key2: {r: 0, g: 0, b: 0, a: 0} + key3: {r: 0, g: 0, b: 0, a: 0} + key4: {r: 0, g: 0, b: 0, a: 0} + key5: {r: 0, g: 0, b: 0, a: 0} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 0} + ctime0: 0 + ctime1: 65535 + ctime2: 0 + ctime3: 0 + ctime4: 0 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 0 + atime1: 65535 + atime2: 0 + atime3: 0 + atime4: 0 + atime5: 0 + atime6: 0 + atime7: 0 + m_Mode: 0 + m_ColorSpace: 0 + m_NumColorKeys: 2 + m_NumAlphaKeys: 2 + numCornerVertices: 0 + numCapVertices: 0 + alignment: 0 + textureMode: 0 + textureScale: {x: 1, y: 1} + shadowBias: 0.5 + generateLightingData: 0 + m_MaskInteraction: 0 + m_UseWorldSpace: 1 + m_Loop: 0 + m_ApplyActiveColorSpace: 1 --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/FixSystemNew/BodyModule/GearFollower.cs b/Assets/Scripts/FixSystemNew/BodyModule/GearFollower.cs index 927052937..a815f3662 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/GearFollower.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/GearFollower.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Shapes; using UnityEngine; public class GearFollower : MonoBehaviour @@ -12,9 +13,12 @@ public class GearFollower : MonoBehaviour [Header("切割轨迹")] public LineRenderer cutLineRenderer; + public float cutLineWidth = 0.1f; public float noiseAmount = 0.05f; // 毛刺偏移幅度 + public float segmentDuration = 4f; // 线段持续时间 + private List edgePoints; private List originalEdgePoints; // 存储原始边缘点 private int currentEdgeIndex = 0; @@ -31,6 +35,20 @@ public class GearFollower : MonoBehaviour private float directionSwitchCooldown = 0.2f; private float directionSwitchTimer = 0f; + private class TimedPoint + { + public Vector3 position; + public float timeAdded; + public TimedPoint(Vector3 pos, float time) + { + position = pos; + timeAdded = time; + } + } + + private List timedCutPoints = new List(); + public float cutLineDelay = 3f; // 延迟几秒才显示轨迹点 + void Start() { mainCamera = Camera.main; @@ -42,6 +60,7 @@ public class GearFollower : MonoBehaviour cutLineRenderer.widthCurve = AnimationCurve.Constant(0, 1, cutLineWidth); cutLineRenderer.material = new Material(Shader.Find("Sprites/Default")); cutLineRenderer.numCapVertices = 0; // 线头不圆滑,显锐利 + cutLineRenderer.sortingOrder = 1; } } @@ -63,6 +82,7 @@ public class GearFollower : MonoBehaviour UpdateTractionState(mouseWorldPos); break; } + UpdateCutLineRenderer(); } private void LoadEdgePointsFromSprite() @@ -127,7 +147,6 @@ public class GearFollower : MonoBehaviour Debug.Log($"边缘点数量:{edgePoints.Count}"); } - private void UpdateFollowState(Vector2 mousePos) { transform.position = mousePos; @@ -149,7 +168,6 @@ public class GearFollower : MonoBehaviour currentState = State.Traction; } } - private void UpdateTractionState(Vector2 mousePos) { Vector2 gearPos = transform.position; @@ -223,7 +241,7 @@ public class GearFollower : MonoBehaviour Vector2 originalFrom = originalEdgePoints[currentEdgeIndex]; Vector2 originalTo = originalEdgePoints[nextIndex]; Vector2 originalTargetPoint = GetClosestPointOnSegment(originalFrom, originalTo, transform.position); - + // 记录切割点(带噪声模拟毛糙) Vector3 noisyPoint = originalTargetPoint; noisyPoint.x += Random.Range(-noiseAmount, noiseAmount); @@ -243,23 +261,48 @@ public class GearFollower : MonoBehaviour private void AddCutPoint(Vector3 point) { - if (cutLinePoints.Count == 0 || Vector3.Distance(cutLinePoints[cutLinePoints.Count - 1], point) > 0.01f) + if (timedCutPoints.Count == 0 || Vector3.Distance(timedCutPoints[timedCutPoints.Count - 1].position, point) > 0.05f) { - cutLinePoints.Add(point); - if (cutLineRenderer != null) + timedCutPoints.Add(new TimedPoint(point, Time.time)); + + // 立即创建片段 + if (timedCutPoints.Count >= 2) { - cutLineRenderer.positionCount = cutLinePoints.Count; - cutLineRenderer.SetPositions(cutLinePoints.ToArray()); + Vector3 prev = timedCutPoints[timedCutPoints.Count - 2].position; + Vector3 curr = timedCutPoints[timedCutPoints.Count - 1].position; + CreateSegment(prev, curr); } } } + private void UpdateCutLineRenderer() + { + if (cutLineRenderer == null) return; + + float currentTime = Time.time; + List visiblePoints = new List(); + + foreach (var timedPoint in timedCutPoints) + { + if (currentTime - timedPoint.timeAdded >= cutLineDelay) + { + visiblePoints.Add(timedPoint.position); + } + else + { + // 这里的点还没到延迟时间,不显示 + } + } + + cutLineRenderer.positionCount = visiblePoints.Count; + if (visiblePoints.Count > 0) + cutLineRenderer.SetPositions(visiblePoints.ToArray()); + } private void EndCutting() { isCutting = false; // 这里可以添加切割结束后的淡出效果等 } - private int FindNearestEdgePointIndex(Vector2 pos, out float minDist) { int nearestIndex = 0; @@ -291,4 +334,20 @@ public class GearFollower : MonoBehaviour if (index >= edgePoints.Count - 1) return 0; return index; } + private void CreateSegment(Vector3 from, Vector3 to) + { + GameObject segObj = new GameObject("HeatLineSegment"); + segObj.transform.parent = this.transform; + + LineRenderer segLine = segObj.AddComponent(); + segLine.positionCount = 2; + segLine.SetPosition(0, from); + segLine.SetPosition(1, to); + segLine.sortingOrder = 4; + segLine.material = new Material(Shader.Find("Sprites/Default")); + segLine.widthCurve = AnimationCurve.Constant(0, 1, cutLineWidth); + segLine.numCapVertices = 0; + var segmentController = segObj.AddComponent(); + segmentController.duration = segmentDuration; + } } diff --git a/Assets/Scripts/FixSystemNew/BodyModule/HeatLineSegmentController.cs b/Assets/Scripts/FixSystemNew/BodyModule/HeatLineSegmentController.cs new file mode 100644 index 000000000..82700390b --- /dev/null +++ b/Assets/Scripts/FixSystemNew/BodyModule/HeatLineSegmentController.cs @@ -0,0 +1,51 @@ +using UnityEngine; +using DG.Tweening; + +public class HeatLineSegmentController : MonoBehaviour +{ + private LineRenderer lineRenderer; + private Sequence sequence; + + public float duration = 4f; // 整个冷却淡出时间 + public Color hotColor = Color.red; + public Color coldColor = Color.black; + + void Awake() + { + lineRenderer = GetComponent(); + if (lineRenderer == null) + { + Debug.LogError("HeatLineSegmentController需要LineRenderer组件"); + } + lineRenderer.startColor = lineRenderer.endColor = hotColor; + } + + void Start() + { + // 创建颜色渐变序列 + sequence = DOTween.Sequence(); + + // 颜色从热色到冷色 + sequence.Append(DOTween.To(() => lineRenderer.startColor, x => { + lineRenderer.startColor = x; + lineRenderer.endColor = x; + }, coldColor, duration * 0.7f).SetEase(Ease.InOutQuad)); + + // 淡出效果 + sequence.Append(DOTween.To(() => lineRenderer.startColor.a, x => { + Color c = lineRenderer.startColor; + c.a = x; + lineRenderer.startColor = c; + lineRenderer.endColor = c; + }, 0f, duration * 0.3f).SetEase(Ease.InQuad)); + + // 完成后销毁对象 + sequence.OnComplete(() => Destroy(gameObject)); + } + + void OnDestroy() + { + // 清理DOTween序列 + sequence?.Kill(); + } +} diff --git a/Assets/Scripts/FixSystemNew/BodyModule/HeatLineSegmentController.cs.meta b/Assets/Scripts/FixSystemNew/BodyModule/HeatLineSegmentController.cs.meta new file mode 100644 index 000000000..b413c6258 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/BodyModule/HeatLineSegmentController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6a522756b1d3f1640981d73f044ab755 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: