- Home /
Question by
andynubianvr · Jan 25, 2020 at 05:59 AM ·
videovideo streaming
Video Manager script always plays the last video index regardless of which index is called
I wrote a video manager-script similar to the audio manager-script created by Brackeys in his video. Unfortunately every time I run the script it ignores the video that has been set to play from the array and always plays the last index for some reason. Here is a code snippet of my video manager-script.
public class VideoPlayerCylinder : MonoBehaviour
{
public Videos[] videoList;
void Awake()
{
foreach (Videos v in videoList)
{
v.videoPlayer = gameObject.GetComponent<VideoPlayer>();
v.videoPlayer.clip = v.videoClip;
v.videoPlayer.isLooping = v.loop;
}
}
public void PlayVideo(string video)
{
Videos v = Array.Find(videoList, item => item.videoName == video);
if (v == null)
{
Debug.LogError("Video:" + video + "not found!");
return;
}
v.videoPlayer.Prepare();
v.videoPlayer.Play();
Debug.Log("Video:" + video + " is prepatring to play");
}
}
Comment
@andynubianvr did u find a solution by any chance?,hey! did you by any chance find a solution ? i have the same problem..
Your answer
![](https://koobas.hobune.stream/wayback/20220612222110im_/https://answers.unity.com/themes/thub/images/avi.jpg)