Reputation: 54260
I got an obsolete warning after updating to 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)
The codes are as follow:
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);
}
}
How should I change the line?
The original codes can be found here.
Upvotes: 1
Views: 4825
Reputation: 23813
WWW
constructor is not expecting an Hashtable
anymore, but a Dictionary
(its generic equivalent)
Do as the warning says : replace your Hashtable header
member with a Dictionary<K,V>
, K being the type of the Keys in the table, V the type of the values.
EDIT:
Also see why is Dictionary preferred over hashtable
Upvotes: 5