Centralize VideoPanel logic in UIManager to solve reference ambiguity

This commit is contained in:
yangbear
2026-07-10 05:01:29 +08:00
parent 80cb7598e6
commit 0abf59a7d7
3 changed files with 45 additions and 57 deletions
+3 -16
View File
@@ -133,23 +133,10 @@ public class PingClickHandler : MonoBehaviour
}
// 隐藏视频面板
var videoController = FindObjectOfType<VideoController>(true);
if (videoController == null)
var uiMgr = FindObjectOfType<UIManager>();
if (uiMgr != null)
{
var allT = Resources.FindObjectsOfTypeAll<Transform>();
foreach (var t in allT)
{
if (t.name == "VideoPanel" && t.parent != null && t.parent.name == "Canvas")
{
t.gameObject.SetActive(false);
break;
}
}
}
else
{
videoController.StopVideo();
videoController.gameObject.SetActive(false);
uiMgr.HideVideo();
}
}
}
@@ -150,28 +150,10 @@ public class ShoseClickHandler : MonoBehaviour
}
// 显示 VideoPanel 并播放视频
var videoController = FindObjectOfType<VideoController>(true);
if (videoController == null)
var uiMgr = FindObjectOfType<UIManager>();
if (uiMgr != null)
{
var allT = Resources.FindObjectsOfTypeAll<Transform>();
foreach (var t in allT)
{
if (t.name == "VideoPanel" && t.parent != null && t.parent.name == "Canvas")
{
videoController = t.gameObject.AddComponent<VideoController>();
break;
}
}
}
if (videoController != null)
{
videoController.gameObject.SetActive(true);
videoController.PlayVideo("tuoXieZi.mp4");
}
else
{
Debug.LogError("[ShoseClick] 未找到 VideoPanel,无法播放视频");
uiMgr.ShowVideo("tuoXieZi.mp4");
}
}
@@ -189,23 +171,10 @@ public class ShoseClickHandler : MonoBehaviour
if (nextObject != null) nextObject.SetActive(false);
// --- 恢复相机2、隐藏视频并重新播放语音 ---
var videoController = FindObjectOfType<VideoController>(true);
if (videoController != null)
var uiMgr = FindObjectOfType<UIManager>();
if (uiMgr != null)
{
videoController.StopVideo();
videoController.gameObject.SetActive(false);
}
else
{
var allT = Resources.FindObjectsOfTypeAll<Transform>();
foreach (var t in allT)
{
if (t.name == "VideoPanel" && t.parent != null && t.parent.name == "Canvas")
{
t.gameObject.SetActive(false);
break;
}
}
uiMgr.HideVideo();
}
var cam2 = GameObject.Find("camera2");