首页 > 编程语言 > 详细

unity本地存取

时间:2021-06-18 23:33:09      阅读:25      评论:0      收藏:0      [点我收藏+]
using UnityEngine;
using System.Collections;

public class local_storage : MonoBehaviour {

    // Use this for initialization
    void Start () {
        //设定数据----不是代码
        // name: 小红 // 字符串
        // age: 12 // 整数 
        // sex: 1 // 性别
        // hight: 1.62 // float

        //存数据
        /*PlayerPrefs.SetString("name", "小红");
        PlayerPrefs.SetInt("age", 12);
        PlayerPrefs.SetInt("sex", 1);
        PlayerPrefs.SetFloat("hight", 1.62f);
        PlayerPrefs.Save();*/

        //取数据
        // Debug.Log(PlayerPrefs.GetString("name"));
        // Debug.Log(PlayerPrefs.GetInt("age"));
        // Debug.Log(PlayerPrefs.GetInt("sex"));
        // Debug.Log(PlayerPrefs.GetFloat("hight"));

        //查找删除
        if (PlayerPrefs.HasKey("name")) {
            Debug.Log("Haskey");//第一次输出这个
            PlayerPrefs.DeleteKey("name");
        }
        else {
            Debug.Log("ELSE NOT FOUND");//第二次输出这个(被第一次删除了,找不到了)
        }
    }
    
    // Update is called once per frame
    void Update () {
    
    }
}

 

unity本地存取

原文:https://www.cnblogs.com/AllNighter/p/14901130.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!