I need to convert a text (numbers only) i downloaded with WWW and then convert it to a int. Here is my current code but it is not working:
using UnityEngine;
using System.Collections;
public class FetchXP : MonoBehaviour {
public GUISkin GUISkin;
public string url = "url";
IEnumerator Start (){
PlayerPrefs.DeleteKey("xp");
WWWForm form = new WWWForm();
form.AddField( "username", PlayerPrefs.GetString("Username"));
WWW download = new WWW( url, form );
yield return download;
if((!string.IsNullOrEmpty(download.error))) {
print( "Error downloading: " + download.error );
} else {
Debug.Log(download.text);
int.Parse(download.text);
PlayerPrefs.SetInt("xp", download.text);
}
}
Errors:
1.(18,37): error CS1502: The best overloaded method match for `UnityEngine.PlayerPrefs.SetInt(string, int)’ has some invalid arguments
2.(18,37): error CS1503: Argument #2' cannot convert
string’ expression to type `int’