fix: 保存woman初始位置,上一步回到step0时能回到起点
- InitWomanSteps()保存_womanInitPos/_womanInitRot - MoveWomanToStep(0)不再跳过,改为恢复到初始位置 - step=0时显示point1(通过UpdateTouchVisibility)
This commit is contained in:
@@ -185,6 +185,15 @@ public class StepManager : MonoBehaviour
|
||||
{
|
||||
_womanObject = GameObject.Find("woman");
|
||||
_touchArrayObject = GameObject.Find("touchArray");
|
||||
|
||||
// 保存初始位置,用于回退到 step 0
|
||||
if (_womanObject != null)
|
||||
{
|
||||
_womanInitPos = _womanObject.transform.position;
|
||||
_womanInitRot = _womanObject.transform.rotation;
|
||||
Debug.Log($"StepManager: woman初始位置已保存 ({_womanInitPos})");
|
||||
}
|
||||
|
||||
var pts = GameObject.Find("womanPointArray");
|
||||
if (pts != null) { _womanMaxStep = pts.transform.childCount; _womanPositions = new Transform[_womanMaxStep]; for (int i = 0; i < _womanMaxStep; i++) _womanPositions[i] = pts.transform.GetChild(i); }
|
||||
if (_touchArrayObject != null) { _touchPoints = new GameObject[_touchArrayObject.transform.childCount]; for (int i = 0; i < _touchPoints.Length; i++) _touchPoints[i] = _touchArrayObject.transform.GetChild(i).gameObject; }
|
||||
@@ -216,10 +225,22 @@ public class StepManager : MonoBehaviour
|
||||
|
||||
private void MoveWomanToStep(int step)
|
||||
{
|
||||
if (_womanObject == null || _womanPositions == null || step <= 0 || step > _womanPositions.Length) return;
|
||||
var t = _womanPositions[step - 1];
|
||||
_womanObject.transform.position = t.position;
|
||||
_womanObject.transform.rotation = t.rotation;
|
||||
if (_womanObject == null || _womanPositions == null) return;
|
||||
if (step < 0 || step > _womanPositions.Length) return;
|
||||
|
||||
if (step == 0)
|
||||
{
|
||||
// 回到初始位置
|
||||
_womanObject.transform.position = _womanInitPos;
|
||||
_womanObject.transform.rotation = _womanInitRot;
|
||||
Debug.Log("StepManager: woman 回到初始位置");
|
||||
}
|
||||
else
|
||||
{
|
||||
var t = _womanPositions[step - 1];
|
||||
_womanObject.transform.position = t.position;
|
||||
_womanObject.transform.rotation = t.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTouchVisibility(int step)
|
||||
@@ -246,4 +267,8 @@ public class StepManager : MonoBehaviour
|
||||
private int _womanMaxStep = 3;
|
||||
private Transform[] _womanPositions;
|
||||
private GameObject[] _touchPoints;
|
||||
|
||||
|
||||
private Vector3 _womanInitPos;
|
||||
private Quaternion _womanInitRot;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user