feat: touchArray 蓝描边 + 顺序显示(点击1→2→3)
- TouchPositionHandler: Start()创建LineRenderer蓝圈描边 - 新增 nextTouchObject 字段实现链式顺序显示 - 点击球体→移动woman→隐藏自己→显示下一个 - 场景初始: 仅point1活跃, 链: point1→point2→point3→null
This commit is contained in:
@@ -8,9 +8,45 @@ 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<LineRenderer>();
|
||||
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;
|
||||
@@ -21,5 +57,17 @@ public class TouchPositionHandler : MonoBehaviour
|
||||
{
|
||||
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} 已隐藏,无下一个");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user