alestane icon

Unity GUILayout

alestane | PRO | 03/19/15 02:20:06 PM UTC | 0 ⭐ | 526 👁️ | Never ⏰ | []
C# |

760 B

|

None

|

0 👍

/

0 👎

using UnityEngine;
using System.Collections;
 
public class HighScores : MonoBehaviour {
    public Rect where;
 
    private Vector2 scrollPosition;
 
    void OnGUI() {
        var scores = Score.GetScores ();
        if (scores != null && scores.Length > 0) {
            GUILayout.BeginArea (where);
            scrollPosition = GUILayout.BeginScrollView (scrollPosition);
            for (int i = 0; i < scores.Length; ++i) {
                GUILayout.BeginHorizontal (GUI.skin.box);
                GUILayout.Label (scores [i].name); //, GUILayout.Width (where.width * 0.2f));
                    GUILayout.Label (scores [i].score.ToString ());//, GUILayout.Width (where.width * 0.2f));
                    GUILayout.Label (scores [i].when.ToString ());
                GUILayout.EndHorizontal ();
            }
            GUI.EndScrollView ();
            GUILayout.EndArea ();
        }
    }
}

Comments