Files
Inter-Face-Off/Assets/Scripts/PasswordScriptThing.cs
2026-01-27 13:02:04 +00:00

61 lines
2.0 KiB
C#

using System;
using UnityEngine.UI;
using UnityEngine;
namespace InterfaceOff.WorldScene
{
public class PasswordScriptThing : MonoBehaviour
{
[SerializeField] private Text PasswordText;
private void OnEnable()
{
PasswordText.text = "";
}
private static bool IsAnyKeyPressed()
{
return Input.GetKeyDown(KeyCode.A) ||
Input.GetKeyDown(KeyCode.B) ||
Input.GetKeyDown(KeyCode.C) ||
Input.GetKeyDown(KeyCode.D) ||
Input.GetKeyDown(KeyCode.E) ||
Input.GetKeyDown(KeyCode.F) ||
Input.GetKeyDown(KeyCode.G) ||
Input.GetKeyDown(KeyCode.H) ||
Input.GetKeyDown(KeyCode.I) ||
Input.GetKeyDown(KeyCode.J) ||
Input.GetKeyDown(KeyCode.K) ||
Input.GetKeyDown(KeyCode.L) ||
Input.GetKeyDown(KeyCode.M) ||
Input.GetKeyDown(KeyCode.N) ||
Input.GetKeyDown(KeyCode.O) ||
Input.GetKeyDown(KeyCode.P) ||
Input.GetKeyDown(KeyCode.Q) ||
Input.GetKeyDown(KeyCode.R) ||
Input.GetKeyDown(KeyCode.S) ||
Input.GetKeyDown(KeyCode.T) ||
Input.GetKeyDown(KeyCode.U) ||
Input.GetKeyDown(KeyCode.V) ||
Input.GetKeyDown(KeyCode.W) ||
Input.GetKeyDown(KeyCode.X) ||
Input.GetKeyDown(KeyCode.Y) ||
Input.GetKeyDown(KeyCode.Z) ||
Input.GetKeyDown(KeyCode.Space);
}
private void Update()
{
if (IsAnyKeyPressed())
{
PasswordText.text += '*';
}
if (PasswordText.text.Length > 12)
{
transform.parent.gameObject.SetActive(false);
}
}
}
}