Fix VideoPanel reference, automatically find Canvas/VideoPanel and add components if missing

This commit is contained in:
yangbear
2026-07-10 04:41:26 +08:00
parent 745b11b7f0
commit 80cb7598e6
4 changed files with 57 additions and 1 deletions
+3
View File
@@ -18,7 +18,10 @@ public class VideoController : MonoBehaviour
private void Awake()
{
if (_rawImage == null) _rawImage = GetComponent<RawImage>();
if (_rawImage == null) _rawImage = gameObject.AddComponent<RawImage>();
if (_videoPlayer == null) _videoPlayer = GetComponentInChildren<VideoPlayer>();
if (_videoPlayer == null) _videoPlayer = gameObject.AddComponent<VideoPlayer>();
if (_videoPlayer != null)
{