fix: ShoseClickHandler加全量点击诊断日志+collider强制enabled+匹配双名称

This commit is contained in:
yangbear
2026-07-06 04:22:18 +08:00
parent 44a87df00b
commit 5a394e8cad
14 changed files with 203 additions and 15 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: df1b92f4f1591463f81c99fd2d5c881b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7385cc8b190ec4f9daf6493085d85c8e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 907d2682209f74665adadfc4a80a48cc
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 765d0bec0824d4f7ca1e4a8bd663954d
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 896fcac97063147398939ca105de81d5
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 834d6e3c6ab3345fe8f4089834d8ae57
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 2ae768ea29bc143f7a6ae42657bca350
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
+6 -6
View File
@@ -349,32 +349,32 @@ PrefabInstance:
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalScale.x
value: 1
value: 0.011181515
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalScale.y
value: 1
value: 0.011181515
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalScale.z
value: 1
value: 0.011181515
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalPosition.x
value: 3.5
value: -8.242
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.5
value: 0.14941
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
propertyPath: m_LocalPosition.z
value: 4.5
value: -8.2853
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: ef5fbbeda893849a285d196510e10634,
type: 3}
@@ -11,14 +11,13 @@ public class ShoseClickHandler : MonoBehaviour
{
var col = GetComponent<Collider>();
if (col == null) col = gameObject.AddComponent<SphereCollider>();
if (col is SphereCollider sc) { sc.radius = 1.2f; sc.isTrigger = false; }
var drag = GetComponent<DraggableObject>();
if (drag != null) Destroy(drag);
col.enabled = true;
if (col is SphereCollider sc) { sc.radius = 1.5f; sc.isTrigger = false; }
CreateOutlineMesh();
StopAllCoroutines();
StartCoroutine(BlinkOutline());
_clicked = false;
Debug.Log($"[ShoseClick] OnEnable outline={_outlineMesh!=null} col={((SphereCollider)col).radius}");
Debug.Log($"[ShoseClick] OnEnable obj={gameObject.name} outline={_outlineMesh!=null} col enabled={col.enabled} radius={((SphereCollider)col).radius}");
}
void CreateOutlineMesh()
@@ -50,13 +49,20 @@ public class ShoseClickHandler : MonoBehaviour
void Update()
{
if (_clicked || !Input.GetMouseButtonDown(0)) return;
foreach (var cam in Camera.allCameras)
var cams = Object.FindObjectsOfType<Camera>();
foreach (var cam in cams)
{
if (!cam.enabled) continue;
var hits = Physics.RaycastAll(cam.ScreenPointToRay(Input.mousePosition), 100f);
var hits = Physics.RaycastAll(cam.ScreenPointToRay(Input.mousePosition), 200f);
if (hits.Length > 0)
{
var names = new System.Text.StringBuilder();
foreach (var h in hits) names.Append(h.collider?.gameObject?.name ?? "null").Append(", ");
Debug.Log($"[ShoseClick] ★ Update click! hits={hits.Length} — {names}");
}
foreach (var h in hits)
{
if (h.collider != null && h.collider.gameObject == gameObject)
if (h.collider != null && (h.collider.gameObject == gameObject || h.collider.gameObject.name == gameObject.name))
{
OnClicked(); return;
}
@@ -67,10 +73,11 @@ public class ShoseClickHandler : MonoBehaviour
void OnClicked()
{
_clicked = true;
Debug.Log("[ShoseClick] ★ 被点击了 ★");
Debug.Log($"[ShoseClick] ★ {gameObject.name} 被点击了 ★");
StopAllCoroutines();
if (_outlineMesh != null) _outlineMesh.enabled = false;
if (targetPoint != null) { transform.position = targetPoint.position; transform.rotation = targetPoint.rotation; }
if (targetPoint != null) { transform.position = targetPoint.position; transform.rotation = targetPoint.rotation; Debug.Log($"[ShoseClick] 移动到 {targetPoint.name}"); }
else Debug.LogWarning("[ShoseClick] targetPoint 为空");
if (nextObject != null) nextObject.SetActive(true);
}
}