-
Notifications
You must be signed in to change notification settings - Fork 0
/
NameForm.cs
42 lines (38 loc) · 1.04 KB
/
NameForm.cs
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
using TMPro;
using UnityEngine;
namespace UnityCustomRankingTemplate.Scripts
{
using static RankingUtils;
public class NameForm : MonoBehaviour
{
[SerializeField] private RankingManager _rankingManager;
[SerializeField] private TMP_InputField _nameField;
private void Start()
{
SetUserNameText();
}
/// <summary>
/// ユーザ名の更新
/// </summary>
public void UpdateUserName()
{
string newName = _nameField.text;
// ユーザ名を更新
_rankingManager.ChangeName(newName);
}
/// <summary>
/// ユーザ名入力欄にテキストをセット
/// </summary>
private void SetUserNameText()
{
if (!PlayerPrefs.HasKey(ClientUserNameKey))
{
_nameField.text = DefaultUserName;
}
else
{
_nameField.text = PlayerPrefs.GetString(ClientUserNameKey);
}
}
}
}