gpt4 book ai didi

c# - UnityEngine.WWW.WWW(string, byte[], System.Collections.Hashtable)' 已过时

转载 作者:太空宇宙 更新时间:2023-11-03 20:05:10 29 4
gpt4 key购买 nike

我在更新到 Unity 4.5 后收到过时警告:

Warning CS0618: UnityEngine.WWW.WWW(string, byte[], System.Collections.Hashtable)' is obsolete:This overload is deprecated. Use the one with Dictionary argument.' (CS0618) (Assembly-CSharp)

代码如下:

public class Request {
public string url;
public NetworkDelegate del;
public WWWForm form;
public byte[] bytes;
public Hashtable header;

// Constructors
public Request(string url, NetworkDelegate del) {
this.url = url;
this.del = del;
}

public Request(string url, NetworkDelegate del, WWWForm form) : this(url, del) {
this.form = form;
}

public Request(string url, NetworkDelegate del, byte[] bytes) : this(url, del) {
this.bytes = bytes;
}

public Request(string url, NetworkDelegate del, byte[] bytes, Hashtable header) : this(url, del, bytes) {
this.header = header;
}

public WWW makeWWW() {
if(header != null) {
return new WWW(url, bytes, header); // problematic line
}
if(bytes != null) {
return new WWW(url, bytes);
}
if(form != null) {
return new WWW(url, form);
}
return new WWW(url);
}
}

我应该如何更改线路?

可以找到原始代码here .

最佳答案

WWW构造函数不期望 Hashtable不再是了,而是一个 Dictionary (它的通用等价物)

按照警告说的做:更换你的Hashtable header成员(member) Dictionary<K,V> , K 是表中 Key 的类型,V 是值的类型。

编辑:

另见 why is Dictionary preferred over hashtable

关于c# - UnityEngine.WWW.WWW(string, byte[], System.Collections.Hashtable)' 已过时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24051528/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com