ar_tourism_flutter_unity/unity/VRProject2/Assets/zhl/zhlScripts/VideoManager.cs
2025-05-14 17:04:13 +08:00

52 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Video;
using System.Collections;
public partial class VideoManager : MonoBehaviour
{
public VideoObject videoPrefab;
public Vector2Int testAmount;
public List<string> urlList;
public List<VideoObject> videoObjects = new();
[ContextMenu("VideoTest")]
public void TestPlayVideo()
{
for (int i = 0; i < testAmount.x; i++)
{
for (int j = 0; j < testAmount.y; j++)
{
// var tempPrefab = videoPrefab.Instantiate()
// .Position(new Vector3(i * 2, j * 2, 0))
// .Show();
// videoObjects.Add(tempPrefab);
}
}
StartCoroutine(LoadAllVideo());
}
IEnumerator LoadAllVideo()
{
// foreach (var video in videoObjects)
// {
// video.SetVideoUrl(GetRandomUrl());
// while (!video.VideoPlayer.isPrepared)
// {
// yield return null;
// }
//}
yield return null;
}
string GetRandomUrl()
{
return urlList[Random.Range(0, urlList.Count - 1)];
}
}