RiftMayhem/Assets/Scripts/SetCharacterName.cs
2025-02-21 18:35:51 +00:00

39 lines
958 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SetCharacterName : SetNickName
{
[SerializeField] protected StringSharedField playerAccountName;
protected PlayerAccountData accountData;
protected override void Start()
{
base.Start();
accountData = PlayerDataHandler.Instance.LoadPlayerAccountData(playerAccountName.Value);
}
public override void OnInputFieldChanged(string value)
{
if(accountData != null)
{
if (accountData.PlayerContainsCharacter(value))
{
button.interactable = false;
return;
}
}
base.OnInputFieldChanged(value);
}
public void SaveCharacterOnAccountData()
{
accountData.AddCharacterToPlayerAccount(insertedName.Value);
PlayerDataHandler.Instance.SavePlayerAccountData(playerAccountName.Value, accountData);
}
}