3
에 GREE c#
API를 사용하여 게임을 만들고 있습니다. 리더 보드에서 모든 (사용자 이름, 점수)에 대해 Action
을 실행하려고합니다. 여기액션에서 액션 호출
public static void LoadBestScoreFromFriends(Action<FriendAndScore> onComplete)
{
Gree.Leaderboard.LoadScores(LEADERBOARD_ID,
UnityEngine.SocialPlatforms.UserScope.FriendsOnly,
UnityEngine.SocialPlatforms.TimeScope.AllTime,
1,
100,
(IScore[] scores) => {
foreach (IScore iscore in scores)
{
// Since the username is needed, a second
// call to the API must be done
Gree.User.LoadUser(iscore.userID,
(Gree.User guser) => {
FriendAndScore friend = new FriendAndScore();
friend.Name = guser.nickname;
friend.Score = "" + iscore.value;
// Run the action for every (nickname, score value)
onComplete(friend);
}, (string error) => {
Debug.Log("Couldn't fetch friend! error: " + error);
});
}
});
}
문제 iscore.value
항상 같은 점이다 :
코드는 다음과 같다. foreach
의 마지막 요소입니다. 이는 foreach
이 루프를 종료 한 후에 LoadUser()
이 끝나기 때문에 의미가 있습니다.
거기서 전화를 걸려면 두 번째 방법을 만들려고했습니다. 같은 뭔가 :
private void GetTheUserAndCallTheAction(Action<FriendAndScore> onComplete, string userID, string score)
{
Gree.User.LoadUser(userID,
(Gree.User guser) => {
FriendAndScore friend = new FriendAndScore();
friend.Name = guser.nickname;
friend.Score = score;
onComplete(friend);
}, (string error) => {
Debug.Log("Couldn't fetch friend! error: " + error);
});
}
나는 내가 이것을 처리하는 더 나은 방법이 있는지 알고 싶어 C#
안돼서입니다.