Centralize VideoPanel logic in UIManager to solve reference ambiguity
This commit is contained in:
@@ -25,7 +25,7 @@ public class UIManager : MonoBehaviour
|
||||
[SerializeField] private Text _dialogueText;
|
||||
|
||||
[Header("=== 画中画视频 ===")]
|
||||
[SerializeField] private VideoController _videoController;
|
||||
[SerializeField] private GameObject _videoPanel;
|
||||
|
||||
[Header("=== 仿真导航栏按钮(旧引用 + Navbar)===")]
|
||||
[SerializeField] private Button _btnFullScreen;
|
||||
@@ -58,6 +58,9 @@ public class UIManager : MonoBehaviour
|
||||
private void Start()
|
||||
{
|
||||
Debug.Log("=== UIManager 初始化开始 ===");
|
||||
|
||||
// 确保视频最开始是隐藏的
|
||||
HideVideo();
|
||||
|
||||
if (_stepManager == null)
|
||||
{
|
||||
@@ -228,11 +231,40 @@ public class UIManager : MonoBehaviour
|
||||
private void ToggleVideo(string fileName, bool active)
|
||||
{
|
||||
Debug.Log($"UIManager: [ToggleVideo] file={fileName}, active={active}");
|
||||
if (_videoController == null) return;
|
||||
if (active && !string.IsNullOrEmpty(fileName))
|
||||
_videoController.PlayVideo(fileName);
|
||||
ShowVideo(fileName);
|
||||
else
|
||||
_videoController.StopVideo();
|
||||
HideVideo();
|
||||
}
|
||||
|
||||
public void ShowVideo(string fileName)
|
||||
{
|
||||
if (_videoPanel != null)
|
||||
{
|
||||
_videoPanel.SetActive(true);
|
||||
var vp = _videoPanel.GetComponentInChildren<UnityEngine.Video.VideoPlayer>(true);
|
||||
if (vp != null)
|
||||
{
|
||||
vp.isLooping = true;
|
||||
string path = System.IO.Path.Combine(Application.streamingAssetsPath, "Videos", fileName);
|
||||
vp.url = path;
|
||||
vp.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("UIManager: 在 _videoPanel 中没有找到 VideoPlayer 组件!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HideVideo()
|
||||
{
|
||||
if (_videoPanel != null)
|
||||
{
|
||||
var vp = _videoPanel.GetComponentInChildren<UnityEngine.Video.VideoPlayer>(true);
|
||||
if (vp != null) vp.Stop();
|
||||
_videoPanel.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateProgressBar()
|
||||
|
||||
Reference in New Issue
Block a user