Ich implementiere Code aus der Einheit in mein Schulprojekt, um serverseitige Highscores hinzuzufügen. http://wiki.unity3d.com/index.php?title=Server_Side_HighscoresUnerwarteter Bezeichner 'hs_post'
aber mein Browser kehrt diesen Fehler - Syntaxerror: Unerwarteter Bezeichner 'hs_post'
URL meines Projekts https://oege.ie.hva.nl/~osengam001/grijptitus/
Snippet von meinem JS-Datei
var secretKey = "jonathantitus"; // Edit this value and make sure it's the same as the one stored on the server
var addScoreUrl = "https://oege.ie.hva.nl/~osengam001/grijptitus/php/addscore.php?"; //be sure to add a ? to your url
var highscoreUrl = "https://oege.ie.hva.nl/~osengam001/grijptitus/php/display.php";
function postScore(username, score) {
//This connects to a server side php script that will add the name and score to a MySQL DB.
// Supply it with a string representing the players name and the players score.
var hash = Md5.Md5Sum(username + titusGevangen + secretKey);
var highscore_url = addScoreUrl + "name=" + WWW.EscapeURL(username) + "&score=" + titusGevangen + "&hash=" + hash;
// Post the URL to the site and create a download object to get the result.
hs_post = WWW(highscore_url);
yield hs_post; // Wait until the download is done
if (hs_post.error) {
print("There was an error posting the high score: " + hs_post.error);
}
}
// Get the scores from the MySQL DB to display in a GUIText.
function getScores() {
gameObject.guiText.text = "Loading Scores";
hs_get = WWW(highscoreUrl);
yield hs_get;
if (hs_get.error) {
print("There was an error getting the high score: " + hs_get.error);
} else {
document.getElementById("beginTekst").innerHTML = hs_get.text; // this is a GUIText that will display the scores in game.
}
}
Diese Fehlermeldung bedeutet, dass der Parser 'yield' nicht erkennt. Welchen Browser benutzen Sie? – melpomene
Ich habe sowohl Safari als auch Chrome ausprobiert und sie geben mir den gleichen Fehler. – Melvin
Nur Firefox unterstützt 'yield' in einer mit' function' definierten Funktion. ES6 benötigt ['function *'] (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*). – melpomene