百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 热门文章 > 正文

unity 中文API之WWW万维网

bigegpt 2024-08-20 10:56 2 浏览

WWW 万维网

Namespace: UnityEngine

Description 描述

Simple access to web pages.

简单的访问网页的类。

This is a small utility module for retrieving the contents of URLs.

这是一个检索URL内容的小工具模块。

You start a download in the background by calling WWW(url) which returns a new WWW object.

你通过连接WWW(url)在后台开始下载,并且返回一个新的WWW对象。

You can inspect the isDone property to see if the download has completed or yield the download object to automatically wait until it is (without blocking the rest of the game).

你可以检查isDone属性来查看是否已经下载完成,或者yield自动等待下载物体,直到它被下载完成(不会影响游戏的其余部分)。

Use it if you want to get some data from a web server for integration with a game such as highscore lists or calling home for some reason. There is also functionality to create textures from images downloaded from the web and to stream & load new web player data files.

如果你想从web服务器上获取一些数据,例如高分列表或者调用主页,可以使用这个,也有一些功能可以使用从web上下载的图片来创建一个纹理,或者下载或加载新的web播放器数据文件。

The WWW class can be used to send both GET and POST requests to the server. The WWW class will use GET by default and POST if you supply a postData parameter.

WWW类可以用来发送GET和POST请求到服务器,WWW类默认使用GET方法,并且如果提供一个postData参数可用POST方法。

See Also: WWWForm for a way to build valid form data for the postData parameter.

参见: WWWForm为postData参数构建可用的表单数据。

Note: URLs passed to WWW class must be '%' escaped.

注意,URL传递到WWW类,必须是%编码。

Note: http://, https:// and file:// protocols are supported on iPhone. ftp:// protocol support is limited to anonymous downloads only. Other protocols are not supported.

注意:iPhone支持http://, https:// 和 file://协议;ftp://协议的支持仅限于匿名下载。其他协议不被支持。

''Note:'' When using file protocol on Windows and Windows Store Apps for accessing local files, you have to specify file:///__ (with three slashes).

注意,当在windows和Windows Store Apps使用文件协议来访问本地文件,需要使用file:///(带有三个斜线)。

Note: The security sandbox present in web-player builds prevents you from accessing content not hosted the server where the webplayer is hosted.

注意:在当前的web播放器构建安全沙箱防止你访问内容没有托管服务器,在哪里web播放器被托管。

JavaScript:

// Get the latest webcam shot from outside "Friday's" in Times Square
var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
function Start () {
	 // Start a download of the given URL
	var www : WWW = new WWW (url);
 
// Wait for download to complete yield www;
 
// assign texture renderer.material.mainTexture = www.texture; } 

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
 public string url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
 IEnumerator Start() {
 WWW www = new WWW(url);
 yield return www;
 renderer.material.mainTexture = www.texture;
 }
}

Variables 变量

assetBundle Streams an AssetBundle that can contain any kind of asset from the project folder.

AssetBundle的数据流,可以包含项目文件夹中的任何类型资源。 audioClip Returns a AudioClip generated from the downloaded data (Read Only).

从下载的数据,返回一个AudioClip。(只读) bytes Returns the contents of the fetched web page as a byte array (Read Only).

以字节组的形式返回获取到的网络页面中的内容(只读)。 bytesDownloaded The number of bytes downloaded by this WWW query (read only).

通过该WWW查询已下载的字节数(只读)。 error Returns an error message if there was an error during the download (Read Only).

返回一个错误消息,在下载期间如果产生了一个错误的话。(只读) isDone Is the download already finished? (Read Only)

判断下载是否已经完成(只读)? movie Returns a MovieTexture generated from the downloaded data (Read Only).

从下载的数据,返回一个MovieTexture(只读)。 progress How far has the download progressed (Read Only).

下载进度有多少(只读)? text Returns the contents of the fetched web page as a string (Read Only).

通过网页获取并以字符串的形式返回内容(只读)。 texture Returns a Texture2D generated from the downloaded data (Read Only).

从下载的数据返回一个Texture2D(只读)。 textureNonReadable Returns a non-readable Texture2D generated from the downloaded data (Read Only).

从下载的数据返回一个非可读的Texture2D(只读)。 threadPriority Priority of AssetBundle decompression thread.

AssetBundle解压缩线程的优先级。 uploadProgress How far has the upload progressed (Read Only).

上传进度有多少(只读)。 url The URL of this WWW request (Read Only).

此WWW请求的URL(只读)。

Constructors 构造器

WWW Creates a WWW request with the given URL.

用给定的URL创建一个WWW请求。

Functions 函数

GetAudioClip Returns an AudioClip generated from the downloaded data (Read Only).

从下载数据,返回一个AudioClip(只读)。 LoadImageIntoTexture Replaces the contents of an existing Texture2D with an image from the downloaded data.

利用一个从下载数据中的图像来替换现有Texture2D。 LoadUnityWeb Loads the new web player data file.

加载新的web播放器数据文件。

Static Functions 静态函数

EscapeURL Escapes characters in a string to ensure they are URL-friendly.

转义字符串中的字符。 LoadFromCacheOrDownload Loads an AssetBundle with the specified version number from the cache. If the AssetBundle is not currently cached, it will automatically be downloaded and stored in the cache for future retrieval from local storage.

从缓存加载带有指定版本号的AssetBundle。如果AssetBundle不在当前缓存,它将自动下载并储存在缓存,以便以后从本地存储检索。 UnEscapeURL Converts URL-friendly escape sequences back to normal text.

将URL的转义字符恢复正常的文本。

相关推荐

悠悠万事,吃饭为大(悠悠万事吃饭为大,什么意思)

新媒体编辑:杜岷赵蕾初审:程秀娟审核:汤小俊审签:周星...

高铁扒门事件升级版!婚宴上‘冲喜’老人团:我们抢的是社会资源

凌晨两点改方案时,突然收到婚庆团队发来的视频——胶东某酒店宴会厅,三个穿大红棉袄的中年妇女跟敢死队似的往前冲,眼瞅着就要扑到新娘的高额钻石项链上。要不是门口小伙及时阻拦,这婚礼造型团队熬了三个月的方案...

微服务架构实战:商家管理后台与sso设计,SSO客户端设计

SSO客户端设计下面通过模块merchant-security对SSO客户端安全认证部分的实现进行封装,以便各个接入SSO的客户端应用进行引用。安全认证的项目管理配置SSO客户端安全认证的项目管理使...

还在为 Spring Boot 配置类加载机制困惑?一文为你彻底解惑

在当今微服务架构盛行、项目复杂度不断攀升的开发环境下,SpringBoot作为Java后端开发的主流框架,无疑是我们手中的得力武器。然而,当我们在享受其自动配置带来的便捷时,是否曾被配置类加载...

Seata源码—6.Seata AT模式的数据源代理二

大纲1.Seata的Resource资源接口源码2.Seata数据源连接池代理的实现源码3.Client向Server发起注册RM的源码4.Client向Server注册RM时的交互源码5.数据源连接...

30分钟了解K8S(30分钟了解微积分)

微服务演进方向o面向分布式设计(Distribution):容器、微服务、API驱动的开发;o面向配置设计(Configuration):一个镜像,多个环境配置;o面向韧性设计(Resista...

SpringBoot条件化配置(@Conditional)全面解析与实战指南

一、条件化配置基础概念1.1什么是条件化配置条件化配置是Spring框架提供的一种基于特定条件来决定是否注册Bean或加载配置的机制。在SpringBoot中,这一机制通过@Conditional...

一招解决所有依赖冲突(克服依赖)

背景介绍最近遇到了这样一个问题,我们有一个jar包common-tool,作为基础工具包,被各个项目在引用。突然某一天发现日志很多报错。一看是NoSuchMethodError,意思是Dis...

你读过Mybatis的源码?说说它用到了几种设计模式

学习设计模式时,很多人都有类似的困扰——明明概念背得滚瓜烂熟,一到写代码就完全想不起来怎么用。就像学了一堆游泳技巧,却从没下过水实践,很难真正掌握。其实理解一个知识点,就像看立体模型,单角度观察总...

golang对接阿里云私有Bucket上传图片、授权访问图片

1、为什么要设置私有bucket公共读写:互联网上任何用户都可以对该Bucket内的文件进行访问,并且向该Bucket写入数据。这有可能造成您数据的外泄以及费用激增,若被人恶意写入违法信息还可...

spring中的资源的加载(spring加载原理)

最近在网上看到有人问@ContextConfiguration("classpath:/bean.xml")中除了classpath这种还有其他的写法么,看他的意思是想从本地文件...

Android资源使用(android资源文件)

Android资源管理机制在Android的开发中,需要使用到各式各样的资源,这些资源往往是一些静态资源,比如位图,颜色,布局定义,用户界面使用到的字符串,动画等。这些资源统统放在项目的res/独立子...

如何深度理解mybatis?(如何深度理解康乐服务质量管理的5个维度)

深度自定义mybatis回顾mybatis的操作的核心步骤编写核心类SqlSessionFacotryBuild进行解析配置文件深度分析解析SqlSessionFacotryBuild干的核心工作编写...

@Autowired与@Resource原理知识点详解

springIOCAOP的不多做赘述了,说下IOC:SpringIOC解决的是对象管理和对象依赖的问题,IOC容器可以理解为一个对象工厂,我们都把该对象交给工厂,工厂管理这些对象的创建以及依赖关系...

java的redis连接工具篇(java redis client)

在Java里,有不少用于连接Redis的工具,下面为你介绍一些主流的工具及其特点:JedisJedis是Redis官方推荐的Java连接工具,它提供了全面的Redis命令支持,且...