写好获取点击位置的名称传入结构体

This commit is contained in:
huyulong 2024-11-25 17:28:47 +08:00
parent 5da149088a
commit 6dbe316c91
2 changed files with 134 additions and 112 deletions

View File

@ -234,9 +234,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -77.1785}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &70259669
@ -271,9 +271,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 14
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -699.6056}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &85104306
@ -1894,9 +1894,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -268.6945}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &437255630
@ -2153,9 +2153,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -220.81549}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &486064259
@ -2191,9 +2191,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -507.223}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &501141510
@ -3025,9 +3025,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 15
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -747.4846}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &596007159
@ -3215,9 +3215,9 @@ RectTransform:
m_Father: {fileID: 666058190}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -148.955}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 54.782}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &612156437
@ -3450,8 +3450,8 @@ MonoBehaviour:
duty:
scene:
sureBtn: {fileID: 1885878473}
raycaster: {fileID: 0}
eventSystem: {fileID: 0}
raycaster: {fileID: 1592869150}
eventSystem: {fileID: 1579865912}
--- !u!1 &625672672
GameObject:
m_ObjectHideFlags: 0
@ -3564,9 +3564,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -651.72656}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &643616498
@ -3641,9 +3641,9 @@ RectTransform:
m_Father: {fileID: 666058190}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -331.301}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 54.782}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &666058189
@ -3858,9 +3858,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -146.935}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &697546171
@ -3895,9 +3895,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 12
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -603.84753}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &709540181
@ -4183,9 +4183,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -86.887}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &758636159
@ -4512,9 +4512,9 @@ RectTransform:
m_Father: {fileID: 666058190}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -27.391}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 54.782}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &800439078
@ -5416,9 +5416,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -125.057495}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &915498361
@ -5453,9 +5453,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -412.33148}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &920236442
@ -5616,9 +5616,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -387.12698}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &969942584
@ -6104,9 +6104,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 11
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -555.9685}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1024742103
@ -6381,9 +6381,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -364.45248}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1064920678
@ -6419,9 +6419,9 @@ RectTransform:
m_Father: {fileID: 666058190}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -270.519}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 54.782}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1071409070
@ -7688,9 +7688,9 @@ RectTransform:
m_Father: {fileID: 666058190}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -392.083}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 54.782}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1295805949
@ -7725,9 +7725,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -172.9365}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1299096198
@ -8133,9 +8133,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -460.21048}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1365202594
@ -9109,9 +9109,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -206.983}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1545028326
@ -9719,9 +9719,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -267.031}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1600693805
@ -9834,9 +9834,9 @@ RectTransform:
m_Father: {fileID: 666058190}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -209.73701}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 54.782}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1646552233
@ -9872,9 +9872,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -567.271}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1666756050
@ -10129,9 +10129,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -327.07898}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1694829370
@ -10247,9 +10247,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -508.08948}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1760202389
@ -10285,9 +10285,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -26.839}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1764460408
@ -10843,9 +10843,9 @@ RectTransform:
m_Father: {fileID: 666058190}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -88.173004}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 54.782}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1879172589
@ -11154,9 +11154,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -29.2995}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1933500136
@ -11817,9 +11817,9 @@ RectTransform:
m_Father: {fileID: 667280287}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -316.5735}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &2039298473
@ -11935,9 +11935,9 @@ RectTransform:
m_Father: {fileID: 1034927193}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 194.0772, y: -447.175}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 53.678}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &2041460956

View File

@ -34,6 +34,12 @@ public class Panel : MonoBehaviour
}
// Update is called once per frame
void Update()
{
GetData();
}
public void SetName()
{
@ -95,22 +101,26 @@ public class Panel : MonoBehaviour
// Update is called once per frame
void Update()
public void GetData()
{
// 当鼠标左键按下时进行检测
if (Input.GetMouseButtonDown(0))
{
// 创建PointerEventData来记录点击事件的数据
// 确保 raycaster 和 eventSystem 不为空
if (raycaster == null || eventSystem == null)
{
Debug.LogError("Raycaster 或 EventSystem 未正确分配,请在 Inspector 中进行分配。");
return;
}
// 创建 PointerEventData 来记录点击事件的数据
PointerEventData pointerData = new PointerEventData(eventSystem);
pointerData.position = Input.mousePosition;
// 用于存储射线检测的结果
List<RaycastResult> results = new List<RaycastResult>();
// 射线检测 UI
raycaster.Raycast(pointerData, results);
// 遍历射线检测的结果
@ -118,19 +128,31 @@ public class Panel : MonoBehaviour
{
// 检测到点击了按钮
Button clickedButton = result.gameObject.GetComponent<Button>();
if (clickedButton != null)
{
// 获取按钮上Text组件的文本内容并赋值给目标Text组件
Text buttonText = clickedButton.GetComponentInChildren<Text>();
if (buttonText != null && clickedButton.tag == Tags.people)
if (buttonText != null && buttonText.tag == Tags.people)
{
name = buttonText.text;
Debug.Log(name);
}
else if (buttonText != null && buttonText.tag == Tags.scene)
{
scene = buttonText.text;
Debug.Log(scene);
}
else if (buttonText != null && buttonText.tag == Tags.duty)
{
duty = buttonText.text;
Debug.Log(duty);
}
}
}
}
}
}