先上图
之前的截图在Y轴上出现问题,已经修复了。工程也修改了
代码中的问题。
原来的方法,Y轴会出现问题
- Color[] pix = screenTex.GetPixels(Mathf.CeilToInt(startX), Mathf.CeilToInt(startY), (int)shotLength, (int)shotHeight);
- cutImageTex = new Texture2D ((int)shotLength, (int)shotHeight,TextureFormat.RGB24,false);
- cutImageTex.SetPixels (pix);
- cutImageTex.Apply ();
复制代码
修改后的方法:
- cutImageTex = new Texture2D ((int)shotLength, (int)shotHeight,TextureFormat.RGB24,false);int startx = Mathf.CeilToInt (startX);
- int starty = Screen.height - Mathf.CeilToInt (startY);int width = (int)shotLength;
- int height = (int)shotHeight;for(int i=0; i<width; i++)
- { int hhh = 0;
- for(int j=height; j>=0; j--) {
- hhh++; Color color = screenTex.GetPixel(startx+i,starty-hhh);
- cutImageTex.SetPixel(i,j,color); }
- }cutImageTex.Apply ();
复制代码
源代码-回复可见:
|
|