Advertisement
alestane

Unity GUILayout

Mar 19th, 2015
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class HighScores : MonoBehaviour {
  5.     public Rect where;
  6.  
  7.     private Vector2 scrollPosition;
  8.  
  9.     void OnGUI() {
  10.         var scores = Score.GetScores ();
  11.         if (scores != null && scores.Length > 0) {
  12.             GUILayout.BeginArea (where);
  13.             scrollPosition = GUILayout.BeginScrollView (scrollPosition);
  14.             for (int i = 0; i < scores.Length; ++i) {
  15.                 GUILayout.BeginHorizontal (GUI.skin.box);
  16.                 GUILayout.Label (scores [i].name); //, GUILayout.Width (where.width * 0.2f));
  17.                     GUILayout.Label (scores [i].score.ToString ());//, GUILayout.Width (where.width * 0.2f));
  18.                     GUILayout.Label (scores [i].when.ToString ());
  19.                 GUILayout.EndHorizontal ();
  20.             }
  21.             GUI.EndScrollView ();
  22.             GUILayout.EndArea ();
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement