Hi Friends,
In my project, I’m trying to pass user-entered text data back and forth between Unity and a database.
Here is the relevant bit of JS in Unity:
function SubmitClicked() {
// Retrieve input data from front end
var usernameVal:String = username;
var passwordVal:String = password;
var prefixVal:String = prefix;
var givenNameVal:String = givenName;
var surnameVal:String = givenName;
var formerNameVal:String = formerName;
var emailVal:String = email;
var reasonVal:String = reason;
var genderVal:String = gender;
var expertiseVal:String = expertise;
var countryVal:String = country;
var language1Val:String = language1;
var language2Val:String = language2;
var language3Val:String = language3;
var affiliationVal:String = affiliation;
var affiliation02Val:String = affiliation02;
var schoolVal:String = school;
var gradYearVal:String = gradYear;
var specialtyVal:String = specialty;
var specialtyYearVal:String = specialtyYear;
var showEmailVal:String = showEmail;
var websiteVal:String = website;
// Create form data to POST to PHP
var formData:WWWForm = new WWWForm();
formData.AddField("username", usernameVal);
formData.AddField("password", passwordVal);
formData.AddField("prefix", prefixVal);
formData.AddField("givenName", givenNameVal);
formData.AddField("surname", surnameVal);
formData.AddField("formerName", formerNameVal);
formData.AddField("email", emailVal);
formData.AddField("reason", reasonVal);
formData.AddField("gender", genderVal);
formData.AddField("expertise", expertiseVal);
formData.AddField("country", countryVal);
formData.AddField("language1", language1Val);
formData.AddField("language2", language2Val);
formData.AddField("language3", language3Val);
formData.AddField("affiliation", affiliationVal);
formData.AddField("affiliation02", affiliation02Val);
formData.AddField("school", schoolVal);
formData.AddField("gradYear", gradYearVal);
formData.AddField("specialty", specialtyVal);
formData.AddField("specialtyYear", specialtyYearVal);
formData.AddField("showEmail", showEmailVal);
formData.AddField("website", websiteVal);
// add data to the DB
yield requestData(registerURL, formData);
// retrieve the data from the server
yield requestData(getUserURL);
// Parse the data and create the markers in the scene
parseVectorPointData(parsedData_HT);
Application.LoadLevel ("thankYou");
}
function parseVectorPointData(vect3Data:Hashtable) {
Debug.Log("parseVectorPointData");
// Cycle through the retrieved data and create visual representation
// of each object that is positioned in 3D space
for (var de:DictionaryEntry in vect3Data) {
// The data currently returned for each index is a series of three values
// x, y, z (Vector3). Data must be split; comma is split point
var parsedValueString:String[] = de.Value.Split([','], System.StringSplitOptions.None);
// convert each point from a string to a float value e.g., '1' -> 1
var usernameVal:float = parseFloat(parsedValueString[0]);
var passwordVal:float = parseFloat(parsedValueString[1]);
var prefixVal:float = parseFloat(parsedValueString[2]);
var givenNameVal:float = parseFloat(parsedValueString[3]);
var surnameVal:float = parseFloat(parsedValueString[4]);
var formerNameVal:float = parseFloat(parsedValueString[5]);
var emailVal:float = parseFloat(parsedValueString[6]);
var reasonVal:float = parseFloat(parsedValueString[7]);
var genderVal:float = parseFloat(parsedValueString[8]);
var expertiseVal:float = parseFloat(parsedValueString[9]);
var countryVal:float = parseFloat(parsedValueString[10]);
var language1Val:float = parseFloat(parsedValueString[11]);
var language2Val:float = parseFloat(parsedValueString[12]);
var language3Val:float = parseFloat(parsedValueString[13]);
var affiliationVal:float = parseFloat(parsedValueString[14]);
var affiliation02Val:float = parseFloat(parsedValueString[15]);
var schoolVal:float = parseFloat(parsedValueString[16]);
var gradYearVal:float = parseFloat(parsedValueString[17]);
var specialtyVal:float = parseFloat(parsedValueString[18]);
var specialtyYearVal:float = parseFloat(parsedValueString[19]);
var showEmailVal:float = parseFloat(parsedValueString[20]);
var websiteVal:float = parseFloat(parsedValueString[21]);
}
}
// Use this for parsing string or URL encoded text
function parseData (stringToParse:String):Hashtable {
var unparsedString:String = stringToParse;
var parsedString:String[] = unparsedString.Split(['&'], System.StringSplitOptions.None);
var parsedData:Hashtable = new Hashtable();
for (var i:int = 0; i < parsedString.Length; i++) {
Debug.Log(parsedString*);*
_ var nameValuePair:String = parsedString*;_
_ var parsedNameValueString:String = nameValuePair.Split([‘=’], System.StringSplitOptions.None);_
_ parsedData.Add(parsedNameValueString[0], parsedNameValueString[1], parsedNameValueString[2], parsedNameValueString[3], parsedNameValueString[4], parsedNameValueString[5], parsedNameValueString[6], parsedNameValueString[7], parsedNameValueString[8], parsedNameValueString[9], parsedNameValueString[10], parsedNameValueString[11], parsedNameValueString[12], parsedNameValueString[13], parsedNameValueString[14], parsedNameValueString[15], parsedNameValueString[16], parsedNameValueString[17], parsedNameValueString[18], parsedNameValueString[19], parsedNameValueString[20]);_
_ }_
_//above line is responsible for the error message below*_
And here is the error that Unity spits out:
> BCE0017: The best overload for the method ‘System.Collections.Hashtable.Add(Object, Object)’ is not compatible with the argument list ‘(String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String, String)’.
Any ideas?
Thanks in advance!
All the Best,
Ess