Skip to content

Instantly share code, notes, and snippets.

@akirayou
Last active October 18, 2018 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akirayou/4f16bfb616f2550cc1efb472213652e4 to your computer and use it in GitHub Desktop.
Save akirayou/4f16bfb616f2550cc1efb472213652e4 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class ImgDump : MonoBehaviour {
public RenderTexture tex;
public VideoPlayer player;
public List<VideoClip> clip;
Texture2D buf;
void Start () {
buf = new Texture2D(
tex.width, tex.height, TextureFormat.ARGB32, false);
VideoStart(0);
}
public void VideoStart(int i)
{
player.clip = clip[i];
player.frame = 0;
player.Play();
}
public void VideoPause()
{
player.Pause();
}
// Update is called once per frame
float dt = 0;
void Update () {
dt += Time.deltaTime;
if (dt > 1)
{
dt = 0;
VideoStart(1);
}
RenderTexture.active = tex;
buf.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);
Debug.Log(buf.GetPixel(50,30));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment