线缆的物理表现

This commit is contained in:
2024-08-28 17:04:13 +08:00
parent a82b020c48
commit 5831a7cf84
17 changed files with 864 additions and 108 deletions
+152
View File
@@ -0,0 +1,152 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3614166255594274803
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9034087187549040666}
- component: {fileID: 8979707155830308861}
- component: {fileID: -3073236352691771152}
m_Layer: 0
m_Name: PhysicLinePrefab
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &9034087187549040666
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3614166255594274803}
serializedVersion: 2
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: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!120 &8979707155830308861
LineRenderer:
serializedVersion: 2
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3614166255594274803}
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: 2100000, guid: 51099a9679b002c46b76c25f9ac139e3, type: 2}
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: 959782197
m_SortingLayer: 5
m_SortingOrder: 0
m_Positions:
- {x: 0, y: 0, z: 0}
m_Parameters:
serializedVersion: 3
widthMultiplier: 1
widthCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0.02299881
value: 0.20912552
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: 6
numCapVertices: 6
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!114 &-3073236352691771152
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3614166255594274803}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1198bee0150e12d4aa20514b2c8f3362, type: 3}
m_Name:
m_EditorClassIdentifier:
segmentPrefab: {fileID: 0}
segmentSpacing: 0.1
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: de9108583f2ddb646a6dc8e87e791e48
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -69,7 +69,10 @@ public class EyeTransitionManager : MonoBehaviour
MainView,
EyeView,
UFView,
MemoryView
MemoryView,
ColorView
// 为未来的视图添加更多状态
}
@@ -123,6 +123,81 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &3590090
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3590091}
- component: {fileID: 3590093}
- component: {fileID: 3590092}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3590091
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3590090}
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: 1652508981}
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: -4.08, y: 0.66}
m_SizeDelta: {x: 2, y: 1.5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &3590092
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3590090}
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: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
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!222 &3590093
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3590090}
m_CullTransparentMesh: 1
--- !u!1 &4115898
GameObject:
m_ObjectHideFlags: 0
@@ -291,7 +366,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -4.42, y: -0.24}
m_AnchoredPosition: {x: -4.06, y: 0.64}
m_SizeDelta: {x: 0.736, y: 0.696}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &7986262
@@ -496,7 +571,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &19183080
RectTransform:
m_ObjectHideFlags: 0
@@ -5201,6 +5276,94 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 583286921}
m_CullTransparentMesh: 1
--- !u!1 &585617289
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 585617290}
- component: {fileID: 585617293}
- component: {fileID: 585617292}
- component: {fileID: 585617291}
m_Layer: 5
m_Name: SocketColor
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &585617290
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 585617289}
m_LocalRotation: {x: -0, y: -0, z: 1, w: 0.0000029504295}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1652508981}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -2.35, y: 0.64}
m_SizeDelta: {x: 0.736, y: 0.696}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &585617291
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 585617289}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c2a37d0f43cb6f14c8011e55a756c448, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &585617292
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 585617289}
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: 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: 83cee37d2be8ac244ad6900c361ef447, 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!222 &585617293
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 585617289}
m_CullTransparentMesh: 1
--- !u!1 &587665586
GameObject:
m_ObjectHideFlags: 0
@@ -5253,7 +5416,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &590852442
RectTransform:
m_ObjectHideFlags: 0
@@ -9462,6 +9625,12 @@ MonoBehaviour:
socket: {fileID: 1451543708}
lineSegment: {fileID: 0}
viewState: 3
- viewPanel: {fileID: 1882925196}
activateButton: {fileID: 590852443}
returnToMainViewButton: {fileID: 254003903}
socket: {fileID: 1451543708}
lineSegment: {fileID: 0}
viewState: 4
--- !u!4 &1102365682
Transform:
m_ObjectHideFlags: 0
@@ -10177,7 +10346,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 11d7356c830440f48bbd0208dde62749, type: 3}
m_Name:
m_EditorClassIdentifier:
visualLineSegmentPrefab: {fileID: 3614166255594274803, guid: 094e209d31320554891f54b63c125b31, type: 3}
physicLineSegmentPrefab: {fileID: 3614166255594274803, guid: de9108583f2ddb646a6dc8e87e791e48, type: 3}
customCursor: {fileID: 1761949063}
--- !u!4 &1182811777
Transform:
@@ -11306,7 +11475,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: -2310062875034526340, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_IsActive
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: -1673691481530324010, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_SortingLayer
@@ -11396,6 +11565,10 @@ PrefabInstance:
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7782309787341107538, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 9218586654918191133, guid: d8489dc41f8c4c9479ba48d5bf39e02e, type: 3}
propertyPath: m_IsActive
value: 0
@@ -13211,7 +13384,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -2.42, y: 2.03}
m_AnchoredPosition: {x: -2.37, y: 2.67}
m_SizeDelta: {x: 0.736, y: 0.696}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1451543708
@@ -14920,9 +15093,11 @@ RectTransform:
- {fileID: 1887941706}
- {fileID: 19183080}
- {fileID: 590852442}
- {fileID: 3590091}
- {fileID: 1079123346}
- {fileID: 7986261}
- {fileID: 1451543707}
- {fileID: 585617290}
- {fileID: 2031366193}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -18032,7 +18207,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1887941706
RectTransform:
m_ObjectHideFlags: 0
@@ -18674,7 +18849,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -0.27, y: -0.06}
m_AnchoredPosition: {x: -0.27, y: 0.57}
m_SizeDelta: {x: 0.736, y: 0.696}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2031366194
Binary file not shown.

After

Width:  |  Height:  |  Size: 521 KiB

@@ -0,0 +1,140 @@
fileFormatVersion: 2
guid: 07f0e92a84eb90c43a1e3ebacb573796
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:
@@ -24,16 +24,16 @@ position: 63,-958
///表示UF模块在当前维修阶段是否已经进入过了
<<declare $EyeUF = false>>
<<indoor>>
<<load_scene 佩佩视觉模块>>
<<jump Treatment>>
//<<load_scene 佩佩视觉模块>>
<<jump Test>>
<<jump OutDoorTalk>>
===
title: Test
position: 537,-1196
---
<<indoor>>
<<load_scene 佩佩视觉模块>>
//<<indoor>>
//<<load_scene 佩佩视觉模块>>
<<set_scissors_mode LineManager true>>
<<set_line_cuttable LineManager MemoryEye true>>
[command name=activate_socket_choice /]
@@ -49,20 +49,20 @@ position: 537,-1196
title: Test2
position: 537,-1196
---
[command name=activate_socket_choice /]
[options /]
-> UFView
<<messagebox MessageBox "warning" "UFModule has error">>
我::插入UFview
<<jump Test2>>
-> EyeView
<<messagebox MessageBox "warning" "EyeModule has error">>
我::插入Eyeview
<<jump Test2>>
-> MemoryView
<<messagebox MessageBox "normal" "MemoryModule is normal">>
我::插入Memoryview
<<jump Test2>>
// [command name=activate_socket_choice /]
// [options /]
// -> UFView
// <<messagebox MessageBox "warning" "UFModule has error">>
// 我::插入UFview
// <<jump Test2>>
// -> EyeView
// <<messagebox MessageBox "warning" "EyeModule has error">>
// 我::插入Eyeview
// <<jump Test2>>
// -> MemoryView
// <<messagebox MessageBox "normal" "MemoryModule is normal">>
// 我::插入Memoryview
// <<jump Test2>>
===
@@ -84,6 +84,7 @@ position: 72,-688
佩佩: 是的,组长。
佩佩: ……
<<jump InDoorTalk>>
===
title: InDoorTalk
position: 74,-513
@@ -31,6 +31,11 @@ public class CustomCursor : MonoBehaviour
// 当禁用自定义光标时,显示默认的鼠标光标
Cursor.visible = true;
}
public void Shake(float intensity, float speed)
{
float shakeAmount = Mathf.Sin(Time.time * speed) * intensity;
transform.rotation = Quaternion.Euler(rotationCorrection + new Vector3(0, 0, shakeAmount));
}
}
@@ -36,12 +36,27 @@ public class InteractiveLineSegment : VisualLineSegment
{
_isCuttable = value;
// Change the color of the line segment based on its cuttability
GetComponent<LineRenderer>().material.color = value ? Color.white : Color.black;
//GetComponent<LineRenderer>().material.color = value ? Color.white : Color.black;
}
}
private bool _isCuttable=false;
public void OnHover()
{
if (IsCuttable)
{
TurnGreen();
}
else
{
TurnRed();
}
}
public void OnHoverExit()
{
TurnGrey();
}
protected override void Awake()
{
base.Awake();
@@ -52,11 +67,26 @@ public class InteractiveLineSegment : VisualLineSegment
Initialize();
}
public void TurnGreen()
{
lineRenderer.material.color = Color.green; // 改变 LineRenderer 的颜色
}
public void TurnGrey()
{
lineRenderer.material.color = Color.grey; // 改变 LineRenderer 的颜色
}
public void TurnRed()
{
lineRenderer.material.color = Color.red; // 改变 LineRenderer 的颜色
}
public void Initialize()
{
TurnGrey();
if (StartTransform == null || EndTransform == null)
{
Debug.LogError("StartTransform or EndTransform is not set.");
@@ -84,5 +114,7 @@ public class InteractiveLineSegment : VisualLineSegment
// Set the position of the BoxCollider2D to the start point
boxCollider.transform.position = StartPoint;
}
}
+128 -69
View File
@@ -5,11 +5,12 @@ using System.Collections.Generic;
using System.Collections;
using AibisDream;
using System.Linq;
using DG.Tweening;
public class LineManager : MonoBehaviour
{
//public GameObject interactiveLineSegmentPrefab;
public GameObject visualLineSegmentPrefab;
public GameObject physicLineSegmentPrefab;
public CustomCursor customCursor; // 自定义光标,你可以在 Inspector 中设置
@@ -41,6 +42,131 @@ public class LineManager : MonoBehaviour
{
return lineSegmentDictionary.Keys;
}
private InteractiveLineSegment currentLineSegment; // 当前要被剪断的线段
private const float LONG_PRESS_THRESHOLD = 3.0f; // 长按阈值,可以根据需要调整
private float longPressTime = 0.0f; // 长按时间
private float detectionRadius=0.4f;
public void CutLine(InteractiveLineSegment originalLineSegment, Vector3 splitPoint)
{
// 如果线段不可剪断,就直接返回,不进行剪断操作
if (!originalLineSegment.IsCuttable)
{
return;
}
// Create the first new line segment
GameObject firstLineSegmentObject = Instantiate(physicLineSegmentPrefab, transform);
PhysicLineSegment firstLineSegment = firstLineSegmentObject.GetComponent<PhysicLineSegment>();
firstLineSegment.Initialize(originalLineSegment.StartTransform.position, splitPoint);
// Create the second new line segment
GameObject secondLineSegmentObject = Instantiate(physicLineSegmentPrefab, transform);
PhysicLineSegment secondLineSegment = secondLineSegmentObject.GetComponent<PhysicLineSegment>();
secondLineSegment.Initialize(originalLineSegment.EndTransform.position,splitPoint);
// Immediately destroy the original line segment
Destroy(originalLineSegment.gameObject);
}
private void AddPhysicsComponents(GameObject lineSegmentObject)
{
// Add Rigidbody2D
Rigidbody2D rb = lineSegmentObject.AddComponent<Rigidbody2D>();
rb.gravityScale = 1; // Enable gravity
// Add HingeJoint2D
HingeJoint2D hinge = lineSegmentObject.AddComponent<HingeJoint2D>();
hinge.anchor = Vector2.zero; // Set the anchor at one end of the line segment
}
public void BindOptionToLineSegment(string lineSegmentName, YarnOption option)
{
InteractiveLineSegment lineSegment = GetLineSegmentByName(lineSegmentName);
if (lineSegment != null)
{
lineSegment.Option = option;
}
}
private void EnterLineSegment(InteractiveLineSegment lineSegment)
{
if (currentLineSegment != null)
{
lineSegment.OnHoverExit();
}
lineSegment.OnHover();
currentLineSegment = lineSegment;
}
private void LongPressLineSegment(InteractiveLineSegment lineSegment)
{
longPressTime += Time.deltaTime;
Vector3 midpoint = (lineSegment.StartPoint + lineSegment.EndPoint) / 2;
// Make the scissors shake and the line segment turn red
if (longPressTime < LONG_PRESS_THRESHOLD)
{
customCursor.Shake(longPressTime * 5.0f, 10.0f); // 抖动强度随时间增加
//lineSegment.TurnRed(longPressTime / LONG_PRESS_THRESHOLD); // 线段变红的程度随时间增加
// Calculate the midpoint of the line segment
// Move the scissors towards the midpoint
//customCursor.transform.DOMove(midpoint, 0.1f);
}
else
{
// Cut the line segment
CutLine(lineSegment,midpoint);
}
}
private void ExitLineSegment()
{
if (currentLineSegment != null)
{
currentLineSegment.TurnGrey();
}
currentLineSegment = null;
}
private void Update()
{
if (isScissorsMode)
{
// Get the position of the mouse in world coordinates
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
// Check if there is a line segment in the scissors' detection range
Collider2D hitCollider = Physics2D.OverlapCircle(mousePosition, detectionRadius);
InteractiveLineSegment hitLineSegment = hitCollider != null ? hitCollider.GetComponent<InteractiveLineSegment>() : null;
if (hitLineSegment != null)
{
EnterLineSegment(hitLineSegment);
if (Input.GetMouseButtonDown(0))
{
longPressTime = 0.0f;
}
else if (Input.GetMouseButton(0))
{
LongPressLineSegment(hitLineSegment);
}
else if (Input.GetMouseButtonUp(0))
{
longPressTime = 0.0f;
//customCursor.ResetRotation(); // 假设你有一个方法来重置剪刀的旋转
//currentLineSegment.ResetColor(); // 假设你有一个方法来重置线段的颜色
}
}
else
{
ExitLineSegment();
}
}
}
private void SetScissorsCursor()
{
@@ -126,74 +252,7 @@ public class LineManager : MonoBehaviour
IsScissorsMode = isEnabled;
}
public void CutLine(InteractiveLineSegment originalLineSegment, Vector3 splitPoint)
{
// 如果线段不可剪断,就直接返回,不进行剪断操作
if (!originalLineSegment.IsCuttable)
{
return;
}
// Create the first new line segment
GameObject firstLineSegmentObject = Instantiate(visualLineSegmentPrefab, transform);
VisualLineSegment firstLineSegment = firstLineSegmentObject.GetComponent<VisualLineSegment>();
firstLineSegment.Initialize(originalLineSegment.StartPoint, splitPoint);
// Create the second new line segment
GameObject secondLineSegmentObject = Instantiate(visualLineSegmentPrefab, transform);
VisualLineSegment secondLineSegment = secondLineSegmentObject.GetComponent<VisualLineSegment>();
secondLineSegment.Initialize(originalLineSegment.EndPoint, splitPoint);
// Immediately destroy the original line segment
Destroy(originalLineSegment.gameObject);
// Shrink and disappear the new line segments
firstLineSegment.ShrinkAndDisappear();
secondLineSegment.ShrinkAndDisappear();
}
public void BindOptionToLineSegment(string lineSegmentName, YarnOption option)
{
InteractiveLineSegment lineSegment = GetLineSegmentByName(lineSegmentName);
if (lineSegment != null)
{
lineSegment.Option = option;
}
}
private void Update()
{
if (Input.GetMouseButtonDown(0) && isScissorsMode)
{
// Convert the mouse position to a 2D ray
Vector2 ray = Camera.main.ScreenToWorldPoint(Input.mousePosition);
// Check if the ray hits a line segment
RaycastHit2D hit = Physics2D.Raycast(ray, Vector2.zero);
if (hit.collider != null)
{
Debug.Log("Raycast hit: " + hit.transform.name);
InteractiveLineSegment originalLineSegment = hit.transform.GetComponent<InteractiveLineSegment>();
if (originalLineSegment != null)
{
Debug.Log("Line segment hit: " + originalLineSegment.name);
CutLine(originalLineSegment,hit.point);
// Check if Option is not null before selecting it
if (originalLineSegment.Option != null)
{
originalLineSegment.Option.SelectOption();
}
}
else
{
//Debug.Log("Hit object is not a line segment");
}
}
}
}
@@ -0,0 +1,83 @@
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(LineRenderer))]
public class PhysicLineSegment : MonoBehaviour
{
public float segmentSpacing = 0.1f;
public int k = 30;
public Vector3 start;
public Vector3 end;
private List<VerletParticle> particles = new List<VerletParticle>();
private List<VerletStick> sticks = new List<VerletStick>();
private LineRenderer lineRenderer;
private int segmentCount;
public float gravity = -9.8f;
public void Initialize(Vector3 start, Vector3 end)
{
this.start = start;
this.end = end;
//originalLength = Vector3.Distance(start, end);
// Calculate the number of segments and the spacing between them
segmentCount = Mathf.RoundToInt(Vector3.Distance(start, end) / segmentSpacing);
lineRenderer = GetComponent<LineRenderer>();
// Initialize particles
for (int i = 0; i < segmentCount; i++)
{
// Calculate the position of the segment
var particle = new VerletParticle(Vector3.Lerp(start, end, i / (float)segmentCount));
particles.Add(particle);
}
// Initialize sticks
for (int i = 0; i < segmentCount - 1; i++)
{
sticks.Add(new VerletStick(particles[i], particles[i + 1], segmentSpacing));
}
// Lock the first particle
particles[0].isLocked = true;
lineRenderer.positionCount = segmentCount;
}
void FixedUpdate()
{
UpdateLine();
for (int i = 0; i < segmentCount; i++)
{
lineRenderer.SetPosition(i, particles[i].position);
}
}
void UpdateLine()
{
// Apply gravity to particles
for (int i = 1; i < particles.Count; i++)
{
particles[i].ApplyForce(Vector3.up * gravity * Time.deltaTime);
particles[i].UpdatePosition(Time.deltaTime);
}
// Update sticks
for (int ik = 0; ik < k; ik++)
{
foreach (var stick in sticks)
{
stick.UpdateStick();
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1198bee0150e12d4aa20514b2c8f3362
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VerletParticle
{
public Vector3 position;
public Vector3 previousPosition;
public bool isLocked;
public VerletParticle(Vector3 position)
{
this.position = position;
this.previousPosition = position;
this.isLocked = false;
}
public void ApplyForce(Vector3 force)
{
Vector3 temp = position;
position += position - previousPosition + force;
previousPosition = temp;
}
public void UpdatePosition(float deltaTime)
{
Vector3 temp = position;
position += (position - previousPosition) * deltaTime;
previousPosition = temp;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cdb6feb01313af04f8abf13c63227196
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,35 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VerletStick
{
private VerletParticle particleA;
private VerletParticle particleB;
private float length;
public float stiffness = 0.8f; // Add this line
public VerletStick(VerletParticle particleA, VerletParticle particleB, float length)
{
this.particleA = particleA;
this.particleB = particleB;
this.length = length;
}
public void UpdateStick()
{
float currentLength = Vector3.Distance(particleA.position, particleB.position);
float difference = length - currentLength;
Vector3 direction = (particleB.position - particleA.position).normalized;
if (!particleA.isLocked)
{
particleA.position -= direction * difference * stiffness; // Change this line
}
if (!particleB.isLocked)
{
particleB.position += direction * difference * stiffness; // Change this line
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4f52ebcdf1c225c48ad6413459d49309
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -23,14 +23,14 @@ public class VisualLineSegment : MonoBehaviour
lineRenderer.SetPosition(1, EndPoint);
}
public void ShrinkAndDisappear()
{
// Shrink the line segment from the end to the start
DOTween.To(() => EndPoint, x => EndPoint = x, StartPoint, 1f)
.OnUpdate(() => {
lineRenderer.SetPosition(0, StartPoint);
lineRenderer.SetPosition(1, EndPoint);
})
.OnComplete(() => Destroy(gameObject));
}
// public void ShrinkAndDisappear()
// {
// // Shrink the line segment from the end to the start
// DOTween.To(() => EndPoint, x => EndPoint = x, StartPoint, 1f)
// .OnUpdate(() => {
// lineRenderer.SetPosition(0, StartPoint);
// lineRenderer.SetPosition(1, EndPoint);
// })
// .OnComplete(() => Destroy(gameObject));
// }
}