小编Jay*_*yme的帖子

从VideoPlayer获取当前的帧纹理

这篇文章中指出,使用新的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)

c# unity-game-engine unity5

2
推荐指数
1
解决办法
5073
查看次数

标签 统计

c# ×1

unity-game-engine ×1

unity5 ×1