Files
2026-02-21 16:45:37 +08:00

29 lines
706 B
C#

using UnityEngine;
using UnityEngine.UI;
namespace ExitGames.Demos.DemoAnimator
{
[RequireComponent(typeof(InputField))]
public class PlayerNameInputField : MonoBehaviour
{
private static string playerNamePrefKey = "PlayerName";
private void Start()
{
string playerName = string.Empty;
InputField component = GetComponent<InputField>();
if (component != null && PlayerPrefs.HasKey(playerNamePrefKey))
{
playerName = (component.text = PlayerPrefs.GetString(playerNamePrefKey));
}
PhotonNetwork.playerName = playerName;
}
public void SetPlayerName(string value)
{
PhotonNetwork.playerName = value + " ";
PlayerPrefs.SetString(playerNamePrefKey, value);
}
}
}