用户工具

站点工具


侧边栏

script:unityengine:classes:wwwform:wwwform

WWWForm 万维网表单

Namespace: UnityEngine

Description 描述

Helper class to generate form data to post to web servers using the WWW class.

JavaScript:

// Grab a screen shot and upload it to a CGI script.
//获取一个截屏并上传到CGI脚本
// The CGI script must be able to hande form uploads.
//该CGI脚本必须能处理表单上传
 
var screenShotURL= "http://www.my-server.com/cgi-bin/screenshot.pl";
 
// Take a screen shot immediately
//立即截屏
function Start() {
	UploadPNG();
}
 
function UploadPNG() {
	// We should only read the screen after all rendering is complete
	//我们应该只在所有渲染完成后读取屏幕
	yield WaitForEndOfFrame();
 
	// Create a texture the size of the screen, RGB24 format
	//创建屏幕大小的纹理,RGB24格式
	var width = Screen.width;
	var height = Screen.height;
	var tex = new Texture2D( width, height, TextureFormat.RGB24, false );
	// Read screen contents into the texture
	//读取屏幕内存到纹理
	tex.ReadPixels( Rect(0, 0, width, height), 0, 0 );
	tex.Apply();
 
	// Encode texture into PNG
	//编码纹理为PNG
	var bytes = tex.EncodeToPNG();
	Destroy( tex );
 
	// Create a Web Form
	//创建一个Web表单
	var form = new WWWForm();
	form.AddField("frameCount", Time.frameCount.
                                    
script/unityengine/classes/wwwform/wwwform.txt · 最后更改: 2016/08/02 05:25 (外部编辑)