因为webplayer的限制,在webplayer上运行unity程序的时候,截屏并不像本地运行程序那样。基本思路是:
1、通过相应的接口把屏幕像素读取到内存,并且encode成png格式;
2、通过wwwform类把png格式的流由服务器接收,并且存在服务器上,做成链接,然用户下载;
unity官方相关的代码例子:
上面的代码段是用在unity程序中的:截取屏幕并生成png格式的流;访问服务器脚本,让改代码接收png格式的流。screenShotURL是wwwform访问的服务器脚本。
1、通过相应的接口把屏幕像素读取到内存,并且encode成png格式;
2、通过wwwform类把png格式的流由服务器接收,并且存在服务器上,做成链接,然用户下载;
unity官方相关的代码例子:
上面的代码段是用在unity程序中的:截取屏幕并生成png格式的流;访问服务器脚本,让改代码接收png格式的流。screenShotURL是wwwform访问的服务器脚本。