You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
1005 B

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;
}
}
}