26 lines
832 B
C#
26 lines
832 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 挂在 touchArray 的每个子球体上,点击时把 woman 移动到 womanPointArray 对应位置。
|
||
|
|
/// 字段用 public 方便代码直接赋值。
|
||
|
|
/// </summary>
|
||
|
|
public class TouchPositionHandler : MonoBehaviour
|
||
|
|
{
|
||
|
|
public Transform targetPosition;
|
||
|
|
public GameObject womanObject;
|
||
|
|
|
||
|
|
private void OnMouseDown()
|
||
|
|
{
|
||
|
|
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 为空");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|