Skip to content

UnityWebRequest (JavaScript)

UnityWebRequest

Scripting Name:Insight.UnityWebRequest

使用 HTTPS 连接进行 Get 和 Post 操作。

此方法不允许构造。请使用 Get 方法或者 Post 方法来获取一个 UnityWebRequest 实例。

  • 在 Web SDK 中无效

Static Methods


Get

static Get(url: string, params?: string): UnityWebRequest;

以 Get 的方式发出一个 HTTPS 请求.

Parameters

  • url : string 请求地址
  • params : string (可选)请求参数,是一个一维的 JSON 字典。如

Post

static Post(url: string, params: string): UnityWebRequest;

以 Post 的方式发出一个 HTTPS 请求.

Parameters

  • url : string 请求地址
  • params : string 请求参数,是一个一维的 JSON 字典。如

Send

static Send(url: string, method: string, header: string, body: string, moduleObject: object, funObject: object): UnityWebRequest;

发送 https 请求

Parameters

  • url : string 请求地址
  • method: string 一般为 Post, Get
  • header: string 头文件,jason string 格式
  • body: string body 参数,jason string 格式
  • moduleObject: object 回调注册类
  • funObject: object 回调注册方法

HttpCallback: function( result )

{

            Insight.Debug.Log( "post happen callback " + result  )

},

OnPointerUp: function()

{

            Insight.UnityWebRequest.Send("https://gw-dongjian.netease.com/.../getTimestamp","POST","","", this, this.HttpCallback);

            Insight.Debug.Log( "post happen"  )

}

Properties


error

type :string

(只读)请求过程中出现错误的描述字符串。

isDone

type :boolean

(只读)是否已经请求完成或者请求出错。

isHttpError

type :boolean

(只读)是否收到了 HTTPS 请求错误的 code。

isNetworkError

type :boolean

(只读)是否收到了网络错误的 code。

uri

type :string

(只读)请求地址。

url

type :string

(只读)请求地址。

method

type :string

(只读)请求过程中出现错误的描述字符串。

method

type :string

(只读)请求方式。

responseCode

type :number

(只读)请求结果代码。

downloadedBytes

type :number

(只读)请求到的字节数。

downloadHandler

type :string