Last active
October 18, 2018 05:51
-
-
Save akirayou/4f16bfb616f2550cc1efb472213652e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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