using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
|
|
|
|
public class PreFilledText : MonoBehaviour
|
|
{
|
|
[System.Serializable]
|
|
private enum Action {String, Int, Float};
|
|
|
|
[SerializeField]
|
|
private TMP_InputField text;
|
|
|
|
[Header("Player Prefs")]
|
|
[SerializeField]
|
|
private Action Type;
|
|
|
|
[SerializeField]
|
|
private string Key;
|
|
|
|
[SerializeField]
|
|
private string DefaultValue;
|
|
|
|
|
|
private void Awake()
|
|
{
|
|
SetText();
|
|
}
|
|
|
|
private void SetText()
|
|
{
|
|
switch (Type)
|
|
{
|
|
case Action.String:
|
|
text.text = PlayerPrefs.GetString(Key, DefaultValue);
|
|
break;
|
|
case Action.Int:
|
|
text.text = PlayerPrefs.GetFloat(Key, int.Parse(DefaultValue)).ToString();
|
|
break;
|
|
case Action.Float:
|
|
text.text = PlayerPrefs.GetFloat(Key, float.Parse(DefaultValue)).ToString();
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
}
|