-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputField.cs
More file actions
44 lines (40 loc) · 1.12 KB
/
Copy pathInputField.cs
File metadata and controls
44 lines (40 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using TMPro;
public class InputField : MonoBehaviour
{
public Panel myPanel;
public TMP_InputField input;
private void Awake()
{
// initialize random keywords for player to type
for (int i = 0; i < myPanel.commands.Length; i++)
{
string rand = RandomStringGenerator(UnityEngine.Random.Range(3, 5));
myPanel.commands[i] = "Type password: " + rand;
myPanel.responses[i] = rand;
}
}
public void InputText(string output)
{
myPanel.ModifyPanel(output.ToUpper());
// clear text
input.Select();
input.text = "";
}
string RandomStringGenerator(int length)
{
string build = "";
char letter;
for (int i = 0; i < length; i++)
{
float flt = UnityEngine.Random.Range(0f, 1f);
int shift = (int)(25 * flt);
letter = Convert.ToChar(shift + 65);
build += letter;
}
return build;
}
}