这篇文章中指出,使用新的Unity VideoPlayer和VideoClip API播放视频时,人们可以“根据需要检索每一帧的纹理”
请问将当前帧作为Texture2D的正确方法是什么?
编辑:
回答之后,我这样做了,但是不起作用:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class AverageColorFromTexture : MonoBehaviour {
public VideoClip videoToPlay;
public Light lSource;
private Color targetColor;
private VideoPlayer videoPlayer;
private VideoSource videoSource;
private Renderer rend;
private Texture tex;
private AudioSource audioSource;
void Start()
{
Application.runInBackground = true;
StartCoroutine(playVideo());
}
IEnumerator playVideo()
{
rend = GetComponent<Renderer>();
videoPlayer = gameObject.AddComponent<VideoPlayer>();
audioSource = gameObject.AddComponent<AudioSource>();
//Disable Play on Awake for both Video and Audio
videoPlayer.playOnAwake = false;
audioSource.playOnAwake = …
Run Code Online (Sandbox Code Playgroud)