using UnityEngine; /// /// 挂在 touchArray 的每个子球体上,点击时把 woman 移动到 womanPointArray 对应位置。 /// 字段用 public 方便代码直接赋值。 /// public class TouchPositionHandler : MonoBehaviour { public Transform targetPosition; public GameObject womanObject; public GameObject nextTouchObject; private void Start() { CreateBlueOutline(); } private void CreateBlueOutline() { // 用 LineRenderer 画一个水平圆环描边 var ringGo = new GameObject("BlueRing"); ringGo.transform.SetParent(transform, false); ringGo.transform.localPosition = Vector3.zero; ringGo.transform.localRotation = Quaternion.Euler(90f, 0, 0); // XZ 平面 var lr = ringGo.AddComponent(); lr.useWorldSpace = false; lr.loop = true; lr.startWidth = 0.02f; lr.endWidth = 0.02f; lr.material = new Material(Shader.Find("Sprites/Default")); lr.startColor = Color.blue; lr.endColor = Color.blue; float r = 0.12f; int segs = 32; lr.positionCount = segs; for (int i = 0; i < segs; i++) { float a = i * 2f * Mathf.PI / segs; lr.SetPosition(i, new Vector3(Mathf.Cos(a) * r, Mathf.Sin(a) * r, 0)); } Debug.Log($"[TouchPosition] {name}: 蓝描边已创建"); } private void OnMouseDown() { Debug.Log($"[TouchPosition] {name}: 被点击"); if (womanObject != null && targetPosition != null) { womanObject.transform.position = targetPosition.position; womanObject.transform.rotation = targetPosition.rotation; Debug.Log($"[TouchPosition] woman 移动到 {targetPosition.name} ({targetPosition.position})"); } else { Debug.LogWarning($"[TouchPosition] {name}: womanObject 或 targetPosition 为空"); } // 顺序显示:隐藏自己,显示下一个 gameObject.SetActive(false); if (nextTouchObject != null) { nextTouchObject.SetActive(true); Debug.Log($"[TouchPosition] {name} 已隐藏 -> {nextTouchObject.name} 已显示"); } else { Debug.Log($"[TouchPosition] {name} 已隐藏,无下一个"); } } }