Unity 数据存储与读取_PlayerPrefs

本文介绍了Unity中的PlayerPrefs数据存储机制,它适用于Mac, Linux, Windows等多个平台,采用Key-Value方式存储,并能处理int、float、string类型的变量。通过PlayerPrefs,开发者可以方便地在游戏运行时进行数据的保存和读取。" 139271473,4848549,安卓固件深入解析:vendor.img分区的修改与作用,"['安卓开发', '系统分区', '驱动程序', '设备定制', '固件修改']
摘要由CSDN通过智能技术生成
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerInfo : MonoBehaviour {


    /// <summary>
    /// 等级
    /// </summary>
    public Text LevelText;
    /// <summary>
    /// 昵称
    /// </summary>
    public Text NameText;
    /// <summary>
    /// 保存
    /// </summary>
    public Button SaveBtn;
    /// <summary>
    /// 读取
    /// </summary>
    public Button LoadBtn;
	// Use this for initialization
	void Start () {

        //PlayerPrefs.DeleteAll();
     

        LevelText = GetByName("LevelText").GetComponent<Text>();
        NameText = GetByName("NameText").GetComponent<Text>();
        SaveBtn = GetByName("SaveBtn").GetComponent<Button>();

        //匿名委托  保存玩家等级和昵称
        SaveBtn.onClick.AddListener(
            () => {
                PlayerPrefs.SetInt("Level
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值