unity---存档方法PlayerPrefs
作者:互联网
存档方法
PlayerPrefs
利用键值对的存储方式
存值的方法: PlayerPrefs.SetString("Name",t);//SetInt,SetFloat
取值的方法: PlayerPrefs.GetString("Name","无");//GetInt,GetFloat 第二个参数为默认值
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TextTest : MonoBehaviour
{
// Start is called before the first frame update
public Text text;
public InputField ifd;
public void Submit(){//提交(保存)
string t= ifd.text.ToString();
PlayerPrefs.SetString("Name",t);
}
public void Delete(){//删除
if(PlayerPrefs.HasKey("Name")){
PlayerPrefs.DeleteKey("Name");
}
//删除所有键
// PlayerPrefs.DeleteAll();
}
public void UpLoad(){//上传
text.text=PlayerPrefs.GetString("Name","无");
}
}
标签:Name,text,void,---,unity,PlayerPrefs,using,public 来源: https://www.cnblogs.com/lxp-blog/p/16222387.html