feat():完成3种模式的基本运行框架

This commit is contained in:
2025-10-18 08:55:38 +08:00
parent 3d03c59dc3
commit 345930843d
39 changed files with 909 additions and 427 deletions

8
Assets/Prefab/UI.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dd3c25578c29f1b46bf226a4019a48aa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,92 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3732398851892431074
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4187954858673434835}
- component: {fileID: 333526988709526953}
- component: {fileID: 4291694443444656529}
- component: {fileID: 2396565921764771254}
m_Layer: 5
m_Name: EditComponent
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4187954858673434835
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3732398851892431074}
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}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &333526988709526953
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3732398851892431074}
m_CullTransparentMesh: 1
--- !u!114 &4291694443444656529
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3732398851892431074}
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!114 &2396565921764771254
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3732398851892431074}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 126d8afe0e304d548dc13c4df6405e17, type: 3}
m_Name:
m_EditorClassIdentifier:
component: {fileID: 0}
IsOpen: 0

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cde7c0684d092944d8c165da0c0368f6
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,135 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &756030608054991821
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1276987115395320878}
- component: {fileID: 7373803104432976654}
m_Layer: 5
m_Name: PlayerEditPanelViwer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1276987115395320878
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 756030608054991821}
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: 8170672926465396806}
m_Father: {fileID: 0}
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!114 &7373803104432976654
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 756030608054991821}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 29d585e25c3a4840871167630b3c7a49, type: 3}
m_Name:
m_EditorClassIdentifier:
IsOpenOnFirstLoad: 0
componentEditViewerPrefab: {fileID: 3732398851892431074, guid: cde7c0684d092944d8c165da0c0368f6,
type: 3}
noEditableTargetPanel: {fileID: 6815803542166296534}
panelRadius: 100
--- !u!1 &6815803542166296534
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8170672926465396806}
- component: {fileID: 7451891650900267429}
- component: {fileID: 6184840204151197881}
m_Layer: 5
m_Name: NoEditableTargetPanel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &8170672926465396806
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815803542166296534}
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: 1276987115395320878}
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: 0, y: 0}
m_SizeDelta: {x: 400, y: 250}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7451891650900267429
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815803542166296534}
m_CullTransparentMesh: 1
--- !u!114 &6184840204151197881
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6815803542166296534}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 35
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 50
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: No Editable Target

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: faba7bc710ad07f4491499290cd8b296
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -229,74 +229,6 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 2021089518} m_Father: {fileID: 2021089518}
m_LocalEulerAnglesHint: {x: 0, y: -39.767, z: 0} m_LocalEulerAnglesHint: {x: 0, y: -39.767, z: 0}
--- !u!1 &382458518
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 382458521}
- component: {fileID: 382458520}
- component: {fileID: 382458519}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &382458519
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 382458518}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &382458520
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 382458518}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &382458521
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 382458518}
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!1 &410087039 --- !u!1 &410087039
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -415,6 +347,26 @@ MonoBehaviour:
m_LightCookieSize: {x: 1, y: 1} m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0} m_LightCookieOffset: {x: 0, y: 0}
m_SoftShadowQuality: 1 m_SoftShadowQuality: 1
--- !u!1 &431100842 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2729643726423589850, guid: b3e24e2df98d14e4ebc08cc68c071afa,
type: 3}
m_PrefabInstance: {fileID: 2088331975902746738}
m_PrefabAsset: {fileID: 0}
--- !u!114 &431100848
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 431100842}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3bdc5380046d4cacb0dd579877f320eb, type: 3}
m_Name:
m_EditorClassIdentifier:
Interactable: 1
lockLevel: 0
--- !u!1 &856668955 --- !u!1 &856668955
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -1175,74 +1127,6 @@ Transform:
- {fileID: 1234629635} - {fileID: 1234629635}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &2084876468
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalPosition.x
value: -1.5440545
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.5792608
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalPosition.z
value: 1.0709323
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 151205406321954705, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8031699868756389050, guid: 396fdaee2868c534e927e0c2d4da65da,
type: 3}
propertyPath: m_Name
value: NormalCardBook
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 396fdaee2868c534e927e0c2d4da65da, type: 3}
--- !u!1001 &2088331975902746738 --- !u!1001 &2088331975902746738
PrefabInstance: PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -1320,7 +1204,11 @@ PrefabInstance:
m_RemovedGameObjects: m_RemovedGameObjects:
- {fileID: 7518175844631896712, guid: b3e24e2df98d14e4ebc08cc68c071afa, type: 3} - {fileID: 7518175844631896712, guid: b3e24e2df98d14e4ebc08cc68c071afa, type: 3}
m_AddedGameObjects: [] m_AddedGameObjects: []
m_AddedComponents: [] m_AddedComponents:
- targetCorrespondingSourceObject: {fileID: 2729643726423589850, guid: b3e24e2df98d14e4ebc08cc68c071afa,
type: 3}
insertIndex: -1
addedObject: {fileID: 431100848}
m_SourcePrefab: {fileID: 100100000, guid: b3e24e2df98d14e4ebc08cc68c071afa, type: 3} m_SourcePrefab: {fileID: 100100000, guid: b3e24e2df98d14e4ebc08cc68c071afa, type: 3}
--- !u!1001 &4976374363246253691 --- !u!1001 &4976374363246253691
PrefabInstance: PrefabInstance:
@@ -1558,6 +1446,4 @@ SceneRoots:
- {fileID: 4976374363246253691} - {fileID: 4976374363246253691}
- {fileID: 8808393704070049945} - {fileID: 8808393704070049945}
- {fileID: 1969328118} - {fileID: 1969328118}
- {fileID: 382458521}
- {fileID: 2084876468}
- {fileID: 2088331975902746738} - {fileID: 2088331975902746738}

View File

@@ -132,7 +132,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 40417856} - component: {fileID: 40417856}
- component: {fileID: 40417855} - component: {fileID: 40417855}
- component: {fileID: 40417854} - component: {fileID: 40417857}
m_Layer: 0 m_Layer: 0
m_Name: EventSystem m_Name: EventSystem
m_TagString: Untagged m_TagString: Untagged
@@ -140,26 +140,6 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!114 &40417854
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 40417853}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &40417855 --- !u!114 &40417855
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -190,7 +170,55 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &165485609 --- !u!114 &40417857
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 40417853}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_XRTrackingOrigin: {fileID: 0}
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018,
type: 3}
m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0
m_CursorLockBehavior: 0
m_ScrollDeltaPerTick: 6
--- !u!224 &165485610 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
m_PrefabInstance: {fileID: 1937221272884345375}
m_PrefabAsset: {fileID: 0}
--- !u!1 &257151344
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@@ -198,48 +226,92 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 165485610} - component: {fileID: 257151345}
- component: {fileID: 165485611} - component: {fileID: 257151348}
- component: {fileID: 257151347}
- component: {fileID: 257151346}
m_Layer: 5 m_Layer: 5
m_Name: PlayerEditPanelViwer m_Name: WatchMode
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!224 &165485610 --- !u!224 &257151345
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 165485609} m_GameObject: {fileID: 257151344}
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_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children: []
- {fileID: 1748531705} m_Father: {fileID: 1780593834}
m_Father: {fileID: 1067459529}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 256.49097, y: 145}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 464.6504, y: 81.36188}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &165485611 --- !u!114 &257151346
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 165485609} m_GameObject: {fileID: 257151344}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 29d585e25c3a4840871167630b3c7a49, type: 3} m_Script: {fileID: 11500000, guid: b1493e2f66aa46bf9c89362bd0d9013d, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
IsOpenOnFirstLoad: 0 IsOpenOnFirstLoad: 1
modeText: {fileID: 257151347}
--- !u!114 &257151347
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 257151344}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 30
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 3
m_MaxSize: 50
m_Alignment: 3
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 'Watch Mode:'
--- !u!222 &257151348
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 257151344}
m_CullTransparentMesh: 1
--- !u!1 &1067459524 --- !u!1 &1067459524
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -445,7 +517,7 @@ GameObject:
- component: {fileID: 1200522804} - component: {fileID: 1200522804}
- component: {fileID: 1200522803} - component: {fileID: 1200522803}
m_Layer: 5 m_Layer: 5
m_Name: Text (Legacy) m_Name: Hp
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@@ -526,81 +598,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1200522801} m_GameObject: {fileID: 1200522801}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!1 &1748531704
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1748531705}
- component: {fileID: 1748531707}
- component: {fileID: 1748531706}
m_Layer: 5
m_Name: EditComponent
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1748531705
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1748531704}
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: 165485610}
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: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1748531706
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1748531704}
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 &1748531707
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1748531704}
m_CullTransparentMesh: 1
--- !u!1 &1780593830 --- !u!1 &1780593830
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -697,6 +694,7 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 1200522802} - {fileID: 1200522802}
- {fileID: 257151345}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
@@ -717,6 +715,124 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
layer: 1 layer: 1
--- !u!1001 &1937221272884345375
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1067459529}
m_Modifications:
- target: {fileID: 756030608054991821, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_Name
value: PlayerEditPanelViwer
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_AnchorMax.x
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1276987115395320878, guid: faba7bc710ad07f4491499290cd8b296,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: faba7bc710ad07f4491499290cd8b296, type: 3}
--- !u!1660057539 &9223372036854775807 --- !u!1660057539 &9223372036854775807
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@@ -0,0 +1,44 @@
using System;
using Gameplay.Player;
using UnityEngine;
using Interface;
namespace Script.Gameplay.Facility
{
public class DoorInteractController : InteractableBaseController, IEditableComponent
{
[SerializeField] private LockLevel lockLevel;
private bool isOpened = false;
public override void Interact(GameObject interactor)
{
if (isOpened)
{
CloseDoor();
isOpened = false;
}
else
{
OpenDoor();
isOpened = true;
}
}
public LockLevel LockLevel => lockLevel;
public void SetActive(bool active)
{
// 实现激活或禁用门的逻辑
Interactable = active;
}
private void OpenDoor()
{
Debug.Log("Open door");
}
private void CloseDoor()
{
Debug.Log("Close door");
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3bdc5380046d4cacb0dd579877f320eb
timeCreated: 1760693181

View File

@@ -1,7 +0,0 @@
namespace Script.Gameplay.Facility
{
public class EditComponent
{
}
}

View File

@@ -1,69 +0,0 @@
using System;
using Gameplay.Player;
using UnityEngine;
using Interface;
namespace Script.Gameplay.Facility
{
public class FacilityController : MonoBehaviour, IInteractable, IEditable
{
public FacilityModifier facilityModifier;
private void Awake()
{
if (facilityModifier == null)
{
facilityModifier = GetComponent<FacilityModifier>();
}
}
private void Start()
{
}
public string GetInteractPrompt()
{
return "";
}
public void Interact(GameObject interactor)
{
}
public void OnGazeEnter(GameObject editor)
{
// 物体弹出按F可交互菜单
}
public void OnGazeExit(GameObject editor)
{
// 物体取消菜单
}
public void OnGazeEnter(PlayerEditController editor)
{
}
public void OnGazeExit(PlayerEditController editor)
{
}
public void BeginEdit()
{
}
public void EndEdit()
{
}
public IEditable GetEditable()
{
return this;
}
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using Gameplay.Player;
using UnityEngine;
using Interface;
namespace Script.Gameplay.Facility
{
public class FacilityEditableController : MonoBehaviour, IEditable
{
public void OnGazeEnter(PlayerEditController editor)
{
}
public void OnGazeExit(PlayerEditController editor)
{
}
public void BeginEdit()
{
}
public void EndEdit()
{
}
public List<IEditableComponent> GetEditableComponents()
{
var components = new List<IEditableComponent>();
foreach (var mb in GetComponentsInChildren<MonoBehaviour>(true))
{
if (mb is IEditableComponent editableComponent)
{
components.Add(editableComponent);
}
}
return components;
}
}
}

View File

@@ -1,27 +0,0 @@
using UnityEngine;
namespace Script.Gameplay.Facility
{
public class FacilityModifier : MonoBehaviour
{
private Transform _transform;
private Collider _collider;
private Rigidbody _rigidbody;
public void ModifyComponent<T>(bool isOpen, T component) where T : Component
{
var targetComponent = this.GetComponent<T>();
if (targetComponent != null)
{
if (isOpen)
{
targetComponent.gameObject.SetActive(true);
}
else
{
targetComponent.gameObject.SetActive(false);
}
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: b1db33a437984a1a8fae09ab8c5de7e4
timeCreated: 1760667210

View File

@@ -0,0 +1,15 @@
namespace Script.Gameplay.Facility
{
public enum LockLevel
{
Red,
Blue,
Yellow,
}
public interface IEditableComponent
{
public LockLevel LockLevel { get; }
public void SetActive(bool active);
}
}

View File

@@ -0,0 +1,30 @@
using UnityEngine;
using Interface;
namespace Script.Gameplay.Facility
{
public abstract class InteractableBaseController : MonoBehaviour, IInteractable
{
public bool Interactable = true;
public string GetInteractPrompt()
{
return "按F进行交互";
}
public virtual void Interact(GameObject interactor)
{
if (!Interactable) return;
Debug.Log($"{gameObject.name} 被 {interactor.name} 交互了!");
}
public void OnGazeEnter(GameObject editor)
{
// 修改鼠标指针或高亮显示物体等
}
public void OnGazeExit(GameObject editor)
{
// 恢复鼠标指针或取消高亮显示物体等
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f5781ad9dd2842a584b8ef333ae75e60
timeCreated: 1760693365

View File

@@ -1,5 +1,8 @@
using UnityEngine; using UnityEngine;
using Gameplay.Player; using Gameplay.Player;
using System.Collections.Generic;
using Script.Gameplay.Facility;
namespace Interface namespace Interface
{ {
public interface IEditable public interface IEditable
@@ -8,6 +11,6 @@ namespace Interface
void OnGazeExit(PlayerEditController editor); // 玩家停止注视时触发 void OnGazeExit(PlayerEditController editor); // 玩家停止注视时触发
void BeginEdit(); void BeginEdit();
void EndEdit(); void EndEdit();
IEditable GetEditable(); List<IEditableComponent> GetEditableComponents();
} }
} }

View File

@@ -1,3 +1,4 @@
using Core;
using UnityEngine; using UnityEngine;
using Interface; using Interface;
using Script.Gameplay.Input; using Script.Gameplay.Input;
@@ -22,10 +23,7 @@ namespace Gameplay.Player
if (playerCamera == null) if (playerCamera == null)
playerCamera = GameObject.FindWithTag("MainCamera").GetComponent<Camera>(); playerCamera = GameObject.FindWithTag("MainCamera").GetComponent<Camera>();
inputManager.Input.Player.SwitchWatchMode.performed += ctx => ControllerLocator.Instance.Register(this);
{
if (currentTarget != null) currentTarget.BeginEdit();
};
} }
void Update() void Update()
@@ -73,6 +71,11 @@ namespace Gameplay.Player
} }
} }
public IEditable GetCurrentTarget()
{
return currentTarget;
}
void OnDrawGizmos() void OnDrawGizmos()
{ {
if(!isDrawGizmos) return; if(!isDrawGizmos) return;

View File

@@ -21,7 +21,13 @@ namespace Gameplay.Player
playerCamera = GameObject.FindWithTag("MainCamera").GetComponent<Camera>(); playerCamera = GameObject.FindWithTag("MainCamera").GetComponent<Camera>();
var input = InputManager.Instance.Input; var input = InputManager.Instance.Input;
input.Player.SwitchWatchMode.performed += ctx => currentTarget.Interact(this.gameObject);; input.Player.Interact.performed += ctx =>
{
if (currentTarget != null)
{
currentTarget.Interact(this.gameObject);
}
};
} }
void Update() void Update()

View File

@@ -1,6 +1,7 @@
using System; using System;
using Script.Gameplay.Input; using Script.Gameplay.Input;
using UnityEngine; using UnityEngine;
using Core;
namespace Gameplay.Player namespace Gameplay.Player
{ {
@@ -10,34 +11,46 @@ namespace Gameplay.Player
Inside, Inside,
Outside Outside
} }
public class PlayerWatchModeSwitcher : MonoBehaviour public class PlayerWatchModeController : MonoBehaviour
{ {
[SerializeField] private Camera cam; [SerializeField] private Camera cam;
public event Action OnEnterInsideWatchMode;
public event Action OnExitInsideWatchMode;
private InputManager inputManager; private InputManager inputManager;
private WatchMode currentMode = WatchMode.Normal; private WatchMode currentMode = WatchMode.Normal;
public WatchMode CurrentWatchMode
{
get => currentMode;
set
{
if (value != WatchMode.Inside)
{
OnExitInsideWatchMode?.Invoke();
}
if (value == WatchMode.Inside)
{
OnEnterInsideWatchMode?.Invoke();
}
currentMode = value;
SwitchWatchMode(currentMode);
}
}
private void Start() private void Start()
{ {
inputManager = InputManager.Instance; inputManager = InputManager.Instance;
SetWatchMode(currentMode);
var input = inputManager.Input; var input = inputManager.Input;
input.Player.SwitchWatchMode.performed += ctx => input.Player.SwitchWatchMode.performed += ctx =>
{ {
currentMode = (WatchMode)(((int)currentMode + 1) % 3); var modeTemp = (WatchMode)(((int)CurrentWatchMode + 1) % 3);
SetWatchMode(currentMode); CurrentWatchMode = modeTemp;
};; };;
}
public void SetWatchMode(WatchMode mode) ControllerLocator.Instance.Register(this);
{
currentMode = mode;
SwitchWatchMode(mode);
} }
// 实现按Tap键实现在WatchMode 3个模式切换并通过SwitchWatchMode设置正确的相机模式 // 实现按Tap键实现在WatchMode 3个模式切换并通过SwitchWatchMode设置正确的相机模式
private void SwitchWatchMode(WatchMode watchMode) private void SwitchWatchMode(WatchMode watchMode)
{ {
switch (watchMode) switch (watchMode)

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 492ef2bd8fce4535b1b8c32d2a3e36ef
timeCreated: 1760695944

View File

@@ -3,7 +3,7 @@ using UnityEngine;
using UnityEngine; using UnityEngine;
namespace UI namespace UI
{ {
public class FacilityComponentEditViewer : MonoBehaviour public class EditableComponentViewer : MonoBehaviour
{ {
public Component component; public Component component;
public bool IsOpen; public bool IsOpen;

View File

@@ -0,0 +1,181 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Core;
using Interface;
using Gameplay.Player;
using Script.Gameplay.Facility;
using UnityEngine;
using Script.Gameplay.Input;
namespace UI
{
// 用于显示和编辑 Facility 上的各个 IEditComponent 组件的 UI 面板
public class PlayerEditViewer : UIBase
{
private PlayerEditController controller;
private PlayerWatchModeController watchModeController;
private IEditable editable;
private List<IEditableComponent> components = new List<IEditableComponent>();
private List<EditableComponentViewer> componentViewers = new List<EditableComponentViewer>();
[SerializeField] private GameObject componentEditViewerPrefab;
[SerializeField] private GameObject noEditableTargetPanel;
[SerializeField] private float panelRadius = 100f;
private InputManager inputManager;
private void Awake()
{
inputManager = InputManager.Instance;
ControllerLocator.Instance.TryGetWait<PlayerEditController>(GetPlayerEditControllerHandle);
ControllerLocator.Instance.TryGetWait<PlayerWatchModeController>(GetPlayerWatchModeControllerHandle);
}
private void Start()
{
inputManager = InputManager.Instance;
}
public void OnEnterInsideWatchMode()
{
this.gameObject.SetActive(true);
if (GetEditableFromController() != null)
{
GetEditableComponentsFromEditable();
ClearComponentUI();
GenerateComponentUI();
}
else
{
//TODO: 这里可能需要显示“无可编辑对象”之类的提示
if (noEditableTargetPanel != null)
{
noEditableTargetPanel.SetActive(true);
}
}
inputManager.SetCursorState(true, CursorLockMode.Confined);
inputManager.SetInputForLook(false);
inputManager.SetInputForMove(false);
}
public void OnExitInsideWatchMode()
{
this.gameObject.SetActive(false);
ClearComponentUI();
if (noEditableTargetPanel != null)
{
noEditableTargetPanel.SetActive(false);
}
inputManager.SetCursorState(true, CursorLockMode.Locked);
inputManager.SetInputForLook(true);
inputManager.SetInputForMove(true);
}
// 获取 PlayerEditController 的回调
private void GetPlayerEditControllerHandle(PlayerEditController editController)
{
controller = editController;
//Debug.Log("PlayerEditViewer obtained PlayerEditController.");
}
// 获取 PlayerWatchModeController 的回调
private void GetPlayerWatchModeControllerHandle(PlayerWatchModeController watchModeCtrl)
{
watchModeController = watchModeCtrl;
watchModeController.OnEnterInsideWatchMode += OnEnterInsideWatchMode;
watchModeController.OnExitInsideWatchMode += OnExitInsideWatchMode;
//Debug.Log("PlayerEditViewer subscribed to WatchMode events.");
}
private IEditable GetEditableFromController()
{
if (controller == null)
{
Debug.Log($"controller is null in {nameof(PlayerEditViewer)}");
return null;
}
return editable = controller.GetCurrentTarget();
}
private void GetEditableComponentsFromEditable()
{
if (editable == null)
{
Debug.Log($"editable is null in {nameof(PlayerEditViewer)}");
return;
}
components = editable.GetEditableComponents()
.Where(c => c != null)
.ToList();
}
private void ClearComponentUI()
{
foreach (var viewer in componentViewers)
{
if (viewer != null)
{
if (Application.isPlaying) Destroy(viewer.gameObject);
else DestroyImmediate(viewer.gameObject);
}
}
componentViewers.Clear();
}
// TODO: 根据 components 生成 UI, 根据拥有的 IEditComponent 的数量动态生成 UI 元素。布局为环绕着面板中心排列(自适应间隔)。
private void GenerateComponentUI()
{
if (components == null || components.Count == 0 || componentEditViewerPrefab == null) return;
// 计算半径:如果有 RectTransform 就根据面板大小自适应,否则使用默认值
float radius = panelRadius;
var rect = GetComponent<RectTransform>();
if (rect != null)
{
radius = Mathf.Min(rect.rect.width, rect.rect.height) * 0.4f;
}
int n = components.Count;
float angleStep = 360f / n;
for (int i = 0; i < n; i++)
{
float angleDeg = angleStep * i;
float angleRad = Mathf.Deg2Rad * angleDeg;
Vector2 localPos = new Vector2(Mathf.Cos(angleRad), Mathf.Sin(angleRad)) * radius;
var go = Instantiate(componentEditViewerPrefab, transform);
go.name = $"{componentEditViewerPrefab.name}_{i}";
var viewer = go.GetComponent<EditableComponentViewer>();
if (viewer != null)
{
componentViewers.Add(viewer);
}
// 如果是 UI 元素,优先设置 RectTransform.anchoredPosition
var childRect = go.GetComponent<RectTransform>();
if (childRect != null)
{
childRect.anchoredPosition = localPos;
childRect.localRotation = Quaternion.identity;
childRect.localScale = Vector3.one;
}
else
{
go.transform.localPosition = new Vector3(localPos.x, localPos.y, 0f);
go.transform.localRotation = Quaternion.identity;
go.transform.localScale = Vector3.one;
}
// 如果预制件包含接收组件的方法(例如 SetComponent通过 SendMessage 传递。若无则忽略。
//go.SendMessage("SetComponent", components[i], SendMessageOptions.DontRequireReceiver);
}
}
}
}

View File

@@ -11,7 +11,7 @@ namespace UI
private PlayerController _playerController; private PlayerController _playerController;
public Text hpText; public Text hpText;
private void Start() private void Awake()
{ {
ControllerLocator.Instance.TryGetWait<PlayerController>(OnGet); ControllerLocator.Instance.TryGetWait<PlayerController>(OnGet);
} }

View File

@@ -0,0 +1,33 @@
using System;
using Core;
using Gameplay.Player;
using UnityEngine;
using UnityEngine.UI;
namespace UI
{
public class PlayerWatchModeViewer : UIBase
{
private PlayerWatchModeController watchModeController;
[SerializeField] private Text modeText;
private void Awake()
{
ControllerLocator.Instance.TryGetWait<PlayerWatchModeController>(OnGet);
}
private void Update()
{
if (watchModeController != null)
{
modeText.text = "Watch Mode: " + watchModeController.CurrentWatchMode.ToString();
}
}
private void OnGet(PlayerWatchModeController watchModeCtrl)
{
watchModeController = watchModeCtrl;
//Debug.Log("PlayerWatchModeViewer obtained PlayerWatchModeController.");
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b1493e2f66aa46bf9c89362bd0d9013d
timeCreated: 1760696175

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 5895badf61464ca6ad9af54cca1a8474
timeCreated: 1760361415

View File

@@ -1,24 +0,0 @@
using System;
using UnityEngine;
using Core;
using Gameplay.Player;
using Script.Gameplay.Facility;
namespace UI
{
public class PlayerEditPanelViewer : UIBase
{
private PlayerEditController controller;
private FacilityController currentFacilityController;
private void Start()
{
}
// 根据currentFacilityController 生成其对应的组件
private void GenerateComponent()
{
}
}
}

View File

@@ -1,17 +0,0 @@
{
"name": "UI",
"rootNamespace": "",
"references": [
"GUID:fd0e97c21c15497f9406b8ee23c1f67e",
"GUID:ceb6a2c14699464ca35be17af198f904"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 65e534cfaf6f474895bcfa96809b48ca
timeCreated: 1760361420