- Home /
Code snippet in c# needing js version
Using the prime 31 Game Center plugin which is written in c#. The response from a listener is a List not an array. In c# the handler does this:
void playerDataLoaded( List<GameCenterPlayer> players )
{
Debug.Log( "playerDataLoaded" );
foreach( GameCenterPlayer p in players )
//string remotePlayerAlias = p.alias;
Debug.Log( p.alias );
}
What is the Javascript (Unityscript) equivalent of this snippet?
Tried this but no go.
import System.Collections.Generic;
var p: String;
var players = new List.<GameCenterPlayer>();
function playerDataLoaded( players )
{
for(GameCenterPlayer in players){
p = players.Alias;
print("p: "+ p);
}
}
Error: "alias is not a member of Object"
Answer by aldonaletto · Dec 16, 2011 at 11:28 PM
I don't know much about lists, but I suppose it should be something like this:
import System.Collections.Generic;
function playerDataLoaded(players: List.<GameCenterPlayer>) { for (GameCenterPlayer player in players){ var p: String = player.Alias; print("p: "+ p); } } I'm not sure if this is the right way to declare the parameter players. You must also check if the property name is defined as alias or Alias in the GameCenterPlayer declaration.
Your answer
Follow this Question
Related Questions
Prime31 Gamecenter Crash when triggering method 1 Answer
Unity Social Platform not working correctly? 0 Answers
GameCenter Post Score? 0 Answers
Prime31 GameCenter 2 Answers
Turn off the completion banner for the Achievement in gamecenter prime31 1 Answer