fix: 修复 manIdle 未播放问题 + 添加 camera2 切换

- RunOpeningFlow 开头强制重置 Animator: SetBool(false) + Play("manIdle")
- Step2 前确保 IsFull=false(适配 Idle→Shoot 过渡条件)
- 黑屏转场后调用 SwitchToCamera2(),启用 camera2、禁用主摄像机
- 所有关键步骤增加详细 Debug.Log
This commit is contained in:
yangbear
2026-06-29 20:35:12 +08:00
parent 8c5412f390
commit c592358ef8
3 changed files with 1187 additions and 13 deletions
+5 -11
View File
@@ -62,10 +62,7 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: IsFull
m_EventTreshold: 0
m_Conditions: []
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -769426376306875324}
m_Solo: 0
@@ -121,12 +118,6 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
- m_Name: IsStart
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@@ -147,7 +138,10 @@ AnimatorStateTransition:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: IsFull
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: -6540800505175465208}
m_Solo: 0
+1128 -1
View File
File diff suppressed because it is too large Load Diff
@@ -73,15 +73,31 @@ public class OpeningFlowController : MonoBehaviour
{
Debug.Log("=== [OpeningFlow] 片头动画流程开始 ===");
// 强制重置 man 所有动画参数,确保从 Idle 状态开始
if (_manAnimator != null)
{
_manAnimator.SetBool("IsStart", false);
_manAnimator.SetBool("IsFull", false);
_manAnimator.Play("manIdle", 0, 0f);
Debug.Log("[OpeningFlow] man Animator 已重置: IsStart=false, IsFull=false, 强制播放 manIdle");
}
else
{
Debug.LogWarning("[OpeningFlow] _manAnimator 为空!");
}
// Step 1: man 和 man2 同时 Idle,持续 _idleDuration 秒
Debug.Log($"[OpeningFlow] Step1: man + man2 Idle ({_idleDuration}s)");
yield return new WaitForSeconds(_idleDuration);
// Step 2: man 投篮动画 Shoot (3.15s)
// 先确保 IsFull=false(因为 Idle→Shoot 过渡条件需要 IsFull=false
Debug.Log("[OpeningFlow] Step2: man Shoot 动画开始");
if (_manAnimator != null)
{
_manAnimator.SetBool("IsFull", false);
_manAnimator.SetBool("IsStart", true);
Debug.Log("[OpeningFlow] man IsStart=true, IsFull=false, 触发 Shoot");
yield return new WaitForSeconds(3.15f);
_manAnimator.SetBool("IsStart", false);
Debug.Log("[OpeningFlow] Step2: man Shoot 动画结束");
@@ -96,6 +112,7 @@ public class OpeningFlowController : MonoBehaviour
if (_manAnimator != null)
{
_manAnimator.SetBool("IsFull", true);
Debug.Log("[OpeningFlow] man IsFull=true, 触发 manfull");
yield return new WaitForSeconds(2.1f);
Debug.Log("[OpeningFlow] Step3: man Fall 动画结束");
}
@@ -104,7 +121,7 @@ public class OpeningFlowController : MonoBehaviour
Debug.LogWarning("[OpeningFlow] _manAnimator 为空,跳过 Step3");
}
// Step 4: 黑幕转场 —— 渐入 -> 切换角色 -> 渐出
// Step 4: 黑幕转场 —— 渐入 -> 切换角色+摄像机 -> 渐出
Debug.Log("[OpeningFlow] Step4: 黑幕转场开始");
yield return StartCoroutine(FadeBlackScreen(0f, 1f));
@@ -113,6 +130,9 @@ public class OpeningFlowController : MonoBehaviour
if (_womanObject != null) { _womanObject.SetActive(true); Debug.Log("[OpeningFlow] woman 已显示"); }
if (_manInjuryObject != null) { _manInjuryObject.SetActive(true); Debug.Log("[OpeningFlow] maninjury 已显示"); }
// 切换摄像机到 camera2
SwitchToCamera2();
yield return new WaitForSeconds(0.3f);
yield return StartCoroutine(FadeBlackScreen(1f, 0f));
@@ -120,6 +140,39 @@ public class OpeningFlowController : MonoBehaviour
onComplete?.Invoke();
}
/// <summary>
/// 切换到 camera2,禁用主摄像机
/// </summary>
private void SwitchToCamera2()
{
var camera2Go = GameObject.Find("camera2");
if (camera2Go != null)
{
var cam2 = camera2Go.GetComponent<Camera>();
if (cam2 != null)
{
cam2.enabled = true;
Debug.Log("[OpeningFlow] camera2 已启用");
}
else
{
Debug.LogWarning("[OpeningFlow] camera2 上没有 Camera 组件!");
}
// 禁用主摄像机(MainCamera 或标签为 MainCamera 的)
var mainCam = Camera.main;
if (mainCam != null)
{
mainCam.enabled = false;
Debug.Log("[OpeningFlow] 主摄像机已禁用");
}
}
else
{
Debug.LogWarning("[OpeningFlow] 未找到 camera2,摄像机未切换");
}
}
private IEnumerator FadeBlackScreen(float fromAlpha, float toAlpha)
{
if (_blackScreenPanel == null || _blackScreenImage == null)