Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Last active September 21, 2018 15:11
Show Gist options
  • Save nabesi777/1c2500c1b3d6d932726567ce69dbe262 to your computer and use it in GitHub Desktop.
Save nabesi777/1c2500c1b3d6d932726567ce69dbe262 to your computer and use it in GitHub Desktop.
Unity&C# Password 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System; //記載漏れに注意 string passwordToEdit = String.Empty;で必要
public class GUIPassword : MonoBehaviour {
string passwordToEdit = String.Empty;
void OnGUI()
{ //"Password"ラベルの表示位置、サイズのx,y
GUI.Label(new Rect(450, 245, 100, 30), "Password");
//テキスト入力ボックスの表示位置、サイズのx,y 入力された文字列は*で表示される
passwordToEdit = GUI.PasswordField(new Rect(450, 270, 200, 20), passwordToEdit, "*"[0], 25);//最大文字入力数
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update() {
//"password"と入力すると"log-in"と出力
if (passwordToEdit == "password")
{
Debug.Log("log-in");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment