fix: 去掉Shoot的while循环,改为纯WaitForSeconds避免干扰Animator

用户已修复Animator Controller中Shoot循环问题,代码端不再需要每帧SetBool(IsFull,false)
This commit is contained in:
yangbear
2026-06-30 00:57:32 +08:00
parent c1f1428d39
commit 1cd201da60
4 changed files with 91 additions and 91 deletions
@@ -4359,7 +4359,7 @@ AnimationClip:
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
@@ -8141,7 +8141,7 @@ AnimationClip:
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
+79 -74
View File
@@ -7003,79 +7003,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1285985825}
m_CullTransparentMesh: 1
--- !u!1001 &1288780310
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalPosition.x
value: -8.082
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.157
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalPosition.z
value: -8.165
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.7071068
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.7071068
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -90
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_Name
value: maninjury
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: de613ce19d622422abbb9e2d63dc7ec6,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: de613ce19d622422abbb9e2d63dc7ec6, type: 3}
--- !u!1 &1329058527
GameObject:
m_ObjectHideFlags: 0
@@ -8187,6 +8114,84 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1381048278
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalPosition.x
value: -8.23723
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.123
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalPosition.z
value: -8.286
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.7127738
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalRotation.x
value: -0.701394
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalRotation.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalRotation.z
value: -0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: -89.078
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -2946660681007051780, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalPosition.y
value: -0
objectReference: {fileID: 0}
- target: {fileID: -2946660681007051780, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_LocalPosition.z
value: -0.836
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 36a64753ffd054a0e98c1efc8590f2a0,
type: 3}
propertyPath: m_Name
value: manInjury
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 36a64753ffd054a0e98c1efc8590f2a0, type: 3}
--- !u!1 &1387451484
GameObject:
m_ObjectHideFlags: 0
@@ -11841,5 +11846,5 @@ SceneRoots:
- {fileID: 1336173886}
- {fileID: 1009553495}
- {fileID: 19129733}
- {fileID: 1288780310}
- {fileID: 119178389}
- {fileID: 1381048278}
@@ -94,7 +94,7 @@ public class OpeningFlowController : MonoBehaviour
{
Debug.Log("=== [OpeningFlow] 片头动画流程开始 ===");
// 重置参数,让 Animator 默认进入 Idle
// 重置参数,默认 Idle
if (_manAnimator != null)
{
_manAnimator.SetBool("IsStart", false);
@@ -106,30 +106,26 @@ public class OpeningFlowController : MonoBehaviour
Debug.Log("[OpeningFlow] Step1: man + man2 Idle (1s)");
yield return new WaitForSeconds(1f);
// Step 2: Shoot (3.15s) —— 每帧锁 IsFull=false
// Step 2: Shoot 3.15s
Debug.Log("[OpeningFlow] Step2: man Shoot 开始 (3.15s)");
if (_manAnimator != null)
{
_manAnimator.SetBool("IsFull", false);
_manAnimator.SetBool("IsStart", true);
float t = 0f;
while (t < 3.15f)
{
t += Time.deltaTime;
_manAnimator.SetBool("IsFull", false);
yield return null;
}
Debug.Log("[OpeningFlow] man IsStart=true, 等待 Shoot 播完");
}
yield return new WaitForSeconds(3.15f);
if (_manAnimator != null)
{
_manAnimator.SetBool("IsStart", false);
Debug.Log("[OpeningFlow] Step2: Shoot 结束");
}
// Step 3: 摔倒 —— 直接 Play 保证播放,不走 Animator 过渡
Debug.Log("[OpeningFlow] Step3: manfall 开始 (直接 Play)");
// Step 3: 摔倒 manfull —— 直接 Play 不走过渡
Debug.Log("[OpeningFlow] Step3: manfall 开始");
if (_manAnimator != null)
{
_manAnimator.Play("manfull", 0, 0f);
Debug.Log("[OpeningFlow] manfull 已触发, 等待 2.1s");
Debug.Log("[OpeningFlow] manfull Play 已触发");
}
yield return new WaitForSeconds(2.1f);
Debug.Log("[OpeningFlow] manfull 播放完成, 停留 2s");
@@ -139,7 +135,6 @@ public class OpeningFlowController : MonoBehaviour
Debug.Log("[OpeningFlow] Step4: 黑幕转场开始");
yield return StartCoroutine(FadeBlackScreen(0f, 1f));
// 隐藏 man 和 man2,显示 woman 和 manInjury
if (_manAnimator != null) { _manAnimator.gameObject.SetActive(false); Debug.Log("[OpeningFlow] man 已隐藏"); }
if (_man2Object != null) { _man2Object.SetActive(false); Debug.Log("[OpeningFlow] man2 已隐藏"); }
if (_womanObject != null) { _womanObject.SetActive(true); Debug.Log("[OpeningFlow] woman 已显示"); }