示例#1
0
        IEnumerator getScreenTexture(ScreenCut cut, int capx, int capy, int capwidth, int capheight)
        {
            yield return(new WaitForEndOfFrame());

            Texture2D t = new Texture2D(capwidth, capheight, TextureFormat.RGB24, true);      //需要正确设置好图片保存格式

            t.ReadPixels(new UnityEngine.Rect(capx, capy, capwidth, capheight), 0, 0, false); //按照设定区域读取像素;注意是以左下角为原点读取
            t.Apply();
            cut.DispatchWith(lib.Event.COMPLETE, t);
        }
示例#2
0
 public void GetScreenCut(ScreenCut cut, int x, int y, int width, int height)
 {
     StartCoroutine(getScreenTexture(cut, x, y, width, height));
 }