From 4147d6e800397a067886bc189eec51434b44ce97 Mon Sep 17 00:00:00 2001 From: yangbear Date: Mon, 29 Jun 2026 20:41:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=BB=91=E5=B9=95?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E6=A0=B9=E5=9B=A0=20?= =?UTF-8?q?=E2=80=94=20BlackScreenPanel=20active=3Dfalse=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20GameObject.Find=20=E6=89=BE=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: BlackScreenPanel 初始 active=false,GameObject.Find() 只能找活跃对象 → _blackScreenPanel 一直为 null → FadeBlackScreen() 直接 yield break 跳过 修复: 1. 场景中激活 BlackScreenPanel(alpha=0 所以视觉不可见) 2. AutoAssignReferences() 增加 FindObjectsOfType(true) 兜底 3. Start() 改为保持 BlackScreenPanel active + alpha=0,而非 SetActive(false) 4. 增加 Debug.Log 确认 BlackScreenPanel 找到状态 --- .../Animation/OpeningFlowController.cs | 52 ++++++++++++------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/Assets/Scripts/Animation/OpeningFlowController.cs b/Assets/Scripts/Animation/OpeningFlowController.cs index 9e99d0d..81e8a30 100644 --- a/Assets/Scripts/Animation/OpeningFlowController.cs +++ b/Assets/Scripts/Animation/OpeningFlowController.cs @@ -9,21 +9,6 @@ using System.Collections; /// public class OpeningFlowController : MonoBehaviour { - [Header("=== 角色引用 ===")] - [SerializeField] private Animator _manAnimator; - [SerializeField] private Animator _man2Animator; - [SerializeField] private GameObject _man2Object; - [SerializeField] private GameObject _womanObject; - [SerializeField] private GameObject _manInjuryObject; - - [Header("=== 黑幕 UI ===")] - [SerializeField] private GameObject _blackScreenPanel; - [SerializeField] private Image _blackScreenImage; - - [Header("=== 时间配置 ===")] - [SerializeField] private float _idleDuration = 2f; - [SerializeField] private float _fadeDuration = 1f; - private void Start() { // 自动查找引用 @@ -32,7 +17,15 @@ public class OpeningFlowController : MonoBehaviour // 初始状态确认:woman 和 maninjury 应该隐藏 if (_womanObject != null) _womanObject.SetActive(false); if (_manInjuryObject != null) _manInjuryObject.SetActive(false); - if (_blackScreenPanel != null) _blackScreenPanel.SetActive(false); + + // BlackScreenPanel:保持 active,但确保 alpha=0(透明不可见) + if (_blackScreenPanel != null) + { + _blackScreenPanel.SetActive(true); + if (_blackScreenImage != null) + _blackScreenImage.color = new Color(0, 0, 0, 0); + Debug.Log("[OpeningFlow] BlackScreenPanel 已就绪,初始透明"); + } // 不自动启动动画流程 —— 等待用户选择模式和固定方式后由 PageController 触发 Debug.Log("[OpeningFlow] 就绪,等待用户选择模式和固定方式。"); @@ -53,9 +46,32 @@ public class OpeningFlowController : MonoBehaviour if (_womanObject == null) _womanObject = GameObject.Find("woman"); if (_manInjuryObject == null) _manInjuryObject = GameObject.Find("maninjury"); - if (_blackScreenPanel == null) _blackScreenPanel = GameObject.Find("BlackScreenPanel"); - if (_blackScreenImage == null && _blackScreenPanel != null) + + // BlackScreenPanel:先用常规 Find,找不到再用 includeInactive 兜底 + if (_blackScreenPanel == null) + _blackScreenPanel = GameObject.Find("BlackScreenPanel"); + if (_blackScreenPanel == null) + { + // 兜底:搜索非活跃对象 + var allImages = FindObjectsOfType(true); + foreach (var img in allImages) + { + if (img.name == "BlackScreenPanel") + { + _blackScreenPanel = img.gameObject; + _blackScreenImage = img; + Debug.Log("[OpeningFlow] BlackScreenPanel 通过 includeInactive 兜底找到"); + break; + } + } + } + if (_blackScreenPanel != null && _blackScreenImage == null) _blackScreenImage = _blackScreenPanel.GetComponent(); + + if (_blackScreenPanel == null) + Debug.LogWarning("[OpeningFlow] BlackScreenPanel 未找到!黑幕转场将不会显示"); + else + Debug.Log($"[OpeningFlow] BlackScreenPanel 已找到: activeInHierarchy={_blackScreenPanel.activeInHierarchy}, Image={_blackScreenImage != null}"); } ///