/// <summary> /// ランキングの表示 /// </summary> /// <param name="rect">表示範囲</param> private void drawRanking(Rect rect) { GUI.Box(rect, ""); GUILayout.BeginArea(rect); GUILayout.Label("Ranking"); if (GUILayout.Button("Get Ranking", GUILayout.MinHeight(30))) { getRankingList(); } // リストがnullでなければ、ランキングを持っている if (rankingList != null) { GUILayout.Space(0.1f); scrollPosition = GUILayout.BeginScrollView(scrollPosition); for (int i = 0; i < rankingList.Count; ++i) { GUILayout.BeginHorizontal(); GUILayout.Label((i + 1).ToString(), GUILayout.MaxWidth(80)); // 順位 GUILayout.Label(Connection.GetRankingUserName(rankingList[i], "userName")); // ユーザ名(追加したフィールド) GUI.skin.label.alignment = TextAnchor.MiddleRight; GUILayout.Label(rankingList[i]["score"].ToString()); // スコア GUI.skin.label.alignment = TextAnchor.MiddleLeft; GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.Space(0.1f); } GUILayout.EndArea(); }
/* * void OnGUI () * { * drawMenu (); * if (rankersList != null) { * // 取得したトップ5ランキングを表示 * for (int i = 0; i < this.rankersList.Count; ++i) { * string userName = Connection.GetRankingUserName (rankersList [i]); * top [i].guiText.text = i + 1 + ". " + userName + " " + this.rankersList [i] ["score"].ToString (); * } * } * yourScore.guiText.text = bestScore; * yourRank.guiText.text = currentRank + " / " + totalPlayer; * } */ public override void OnVRGUI() { drawTitle(); drawMenu(); if (rankersList != null) { // 取得したトップ5ランキングを表示 for (int i = 0; i < this.rankersList.Count; ++i) { string userName = Connection.GetRankingUserName(rankersList [i]); top [i].guiText.text = i + 1 + ". " + userName + " " + this.rankersList [i] ["score"].ToString(); } } yourScore.guiText.text = bestScore; yourRank.guiText.text = currentRank + " / " + totalPlayer; int txtW = 300, txtH = 100; GUI.TextField(new Rect(Screen.width * 1 / 2 - txtW, Screen.height * 1 / 6, txtW, txtH), "Your score: " + bestScore); GUI.TextField(new Rect(Screen.width * 1 / 2 - txtW, Screen.height * 1 / 6 + txtH, txtW, txtH), "Current rank" + currentRank + " / " + totalPlayer); }