/// <summary> /// ランキング表示を更新する /// </summary> /// <param name="ranking"></param> public void SetRanking(RankingBoard ranking) { RemoveAllContent(); foreach (var element in ranking.Entries.Select((entry, index) => new { entry, index })) { RankingEntryPanel panel = RankingEntryPanel.CreateRankingEntryPanel( prefab: entryPanelPrefab, number: element.index + 1, entry: element.entry); panel.transform.SetParent(content, worldPositionStays: false); } }
private void Start() { service = new FirebaseService(); ranking = new RankingBoard(service); // サインインの実行 signInButton.onClick.AddListener(() => { if (service.IsSignedIn()) { return; } service.SignInAnonymouslyAsync().ContinueWith(task => { if (!task.IsFaulted) { // 成功時 Debug.Log("Authentication completed"); Debug.Log("uid : " + task.Result.UserId); } else { // 失敗時 Debug.LogException(task.Exception); } }, TaskScheduler.FromCurrentSynchronizationContext()); }); // スコアの登録 registerButton.onClick.AddListener(() => { ranking.AddEntry( entry: new RankingEntry(nameField.text, int.Parse(scoreField.text)), onComplete: () => { // 成功時 Debug.Log("registered"); }, onError: (exception) => { // 失敗時 Debug.LogException(exception); }); }); // ランキングの取得 fetchButton.onClick.AddListener(() => { ranking.UpdateEntries( onComplete: () => { // 成功時 ranking.Entries.ForEach(e => Debug.Log(e.ToString())); rankingPanel.SetRanking(ranking); }, onError: (exception) => { // 失敗時 Debug.LogException(exception); }); }); }