using System.Collections; using System.Collections.Generic; using UnityEngine; public class script1 : MonoBehaviour { string nowtime, n1, n2, n3, myname, output; // Start is called before the first frame update void Start() { n1 = "0"; n2 = "0"; n3 = "0"; myname = ""; output = "message"; } // Update is called once per frame void Update() { nowtime = System.DateTime.Now.ToString(); n3 = (int.Parse(n1) + int.Parse(n2)).ToString(); } void OnGUI() { //GUILayout.BeginArea(new Rect(10, 10, 200, 100)); GUILayout.Label("現在日期時間:" + nowtime); GUILayout.BeginHorizontal("box1"); n1 = GUILayout.TextField(n1, 20); GUILayout.Label(" + "); n2 = GUILayout.TextField(n2, 20); GUILayout.Label(" = "); GUILayout.TextField(n3, 20); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal("box2"); GUILayout.Label("帳號:"); myname = GUILayout.TextField(myname); if (GUILayout.Button("Login")) { if (myname == "abc") output = "登入成功"; else output = "登入失敗"; } GUILayout.EndHorizontal(); //output red color label var style2 = new GUIStyle(GUI.skin.label); style2.normal.textColor = Color.red; GUILayout.Label(output, style2); //GUILayout.EndArea(); } }