Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 10th, 2012  |  syntax: C#  |  size: 1.08 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class LoginWindow : WindowBase
  5. {
  6.         private string username = "";
  7.         private string password = "";
  8.         // Use this for initialization
  9.         protected override void Start ()
  10.         {
  11.                 base.Start();
  12.                 initializeWindow("Login",new Rect((Screen.width * 0.5f) - 150,Screen.height * 0.5f,300,150),3,KeyCode.T,LoginFunc,true);
  13.         }
  14.        
  15.         protected override void Update()
  16.         {
  17.                 base.Update();
  18.         }
  19.         // Update is called once per frame
  20.         protected override void OnGUI ()
  21.         {
  22.                 base.OnGUI();
  23.         }
  24.         void LoginFunc(int id)
  25.         {
  26.                 GUI.Label(new Rect(xySpacing.x,(xySpacing.y + 20),75,20),"Account: ");
  27.                 username = GUI.TextField(new Rect(xySpacing.x + 75,(xySpacing.y + 20),125,20),username);
  28.                
  29.                 GUI.Label(new Rect(xySpacing.x,(xySpacing.y + 40),75,20),"Password: ");
  30.                 password = GUI.PasswordField(new Rect(xySpacing.x + 75,(xySpacing.y +  40),125,20),password,'*');
  31.                 if(GUI.Button(new Rect(windowRect.width * 0.5f,(windowRect.height - xySpacing.y) - 35,125,35),"Login"))
  32.                 {
  33.                         Debug.Log("Logging in. Account: " + username + "password: " + password);
  34.                 }
  35.         }
  36. }