unity文件保存读取PlayerPrefs.SetInt   And  PlayerPrefs.GetInt

using UnityEngine;

using System.Collections;

using UnityEngine.UI;

using UnityEngine.SceneManagement;

using Enums;

//定义类管理时间静态变量

public class global_Mgr

{

//定义初始时间

public static int GoodTime01 = 366;

//公共静态方法、参数string str, int  CurrentTime

public static void CurrentTimes(string str, int  CurrentTime)

{

//判断执行

switch (str)

{

case "Level1":

{

if (CurrentTime < GoodTime01)

{

GoodTime01 = CurrentTime;

}

//保存最佳时间数据

PlayerPrefs.SetInt("GoodTimeInt01", GoodTime01);

}

break;

default:  Debug.Log("error");

break;

}

}

}

using System.Collections;

using UnityEngine;

//playercontrol控制到达的时间

public class playercontrol : MonoBehaviour

{

//场景名称

public GameObject Levels=Level01;

//定义初始时间

private float times=0;

//时间累加

private void Update()

{

times += Time.deltaTime;

}

//碰撞触发时结束、记录时间

public void OnTriggerEnter(Collider other)

{

//触发物体

if (other.name.Equals("Endpoint"))

{

int timess = (int)times;

//调用global_Mgr中方法

global_Mgr.CurrentTimes(Levels.name, timess);

}

}

}

using System.Collections;

using UnityEngine.SceneManagement;

using UnityEngine;

//主场景

public class MainMenuScene : MonoBehaviour

{

//场景运行的时候读取时间

public void Awake()

{

global_Mgr.GoodTime01 = PlayerPrefs.GetInt("GoodTimeInt01");

}

}

注:unity文件 PlayerPrefs保存 And  PlayerPrefs读取、用于string、int、float类型,存取数据可在系统regedit注册表编辑器中进行删除...

unity文件 PlayerPrefs.SetInt 保存 And PlayerPrefs.GetInt读取的更多相关文章

  1. Unity日常记录-本地保存未来时间实现倒计时

    本地保存未来时间实现倒计时 TimeTool工具类:获取当前时间.未来时间.两时间差 using System; using UnityEngine; public class TimeTool { ...

  2. 【Unity系统知识】之unity文件操作路径

    IOS:Application.dataPath :                      Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx ...

  3. 以流方式读写文件:文件菜单打开一个文件,文件内容显示在RichTexBox中,执行复制、剪切、粘贴后,通过文件菜单可以保存修改后的文件。

    MainWindow.xaml文件 <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&q ...

  4. 1、Qt Project之基本文件打开与保存

    基本文件打开与保存: 首先是涉及到的头文件,我们需要在mainwindow.h包含头文件: #include <QFileDialog> #include <QFile> #i ...

  5. centos下修改文件后如何保存退出

    centos下修改文件后如何保存退出 保存命令 按ESC键 跳到命令模式,然后: :w 保存文件但不退出vi :w file 将修改另外保存到file中,不退出vi :w! 强制保存,不推出vi :w ...

  6. springboot-用logback将日志文件按等级保存到不同文件

    springboot-用logback将日志文件按等级保存到不同文件 案例: 例如项目基本包名为com.xxx,将该包下的所有日志按debug.info.warn.error等级分别保存到D:/log ...

  7. 点滴积累【C#】---C#实现上传word以流形式保存到数据库和读取数据库中的word文件。

    本文修改来源:http://www.cnblogs.com/zmgdpg/archive/2005/03/31/129758.html 效果: 数据库: 思路: 首先保存word到数据库:获取上传文件 ...

  8. CAD保存DWG文件,设置保存的文件版本号和密码

    主要用到函数说明: MxDrawXCustomFunction::Mx_SaveDwgEx 保存DWG文件,可以设置保存的文件版本号和密码,详细说明如下: 参数 说明 IN CString sFile ...

  9. MATLAB实例:新建文件夹,保存.mat文件并保存数据到.txt文件中

    MATLAB实例:新建文件夹,保存.mat文件并保存数据到.txt文件中 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 用MATLAB实现:指定路径下 ...

随机推荐

  1. BZOJ 4034[HAOI2015]树上操作(树链剖分)

    Description 有一棵点数为 N 的树,以点 1 为根,且树点有边权.然后有 M 个操作,分为三种:操作 1 :把某个节点 x 的点权增加 a .操作 2 :把某个节点 x 为根的子树中所有点 ...

  2. CString::MakeLower Crash

    记录一下使用CString::MakeLower可能导致的crash的一个问题: 问题重现: int _tmain(int argc, _TCHAR* argv[]){ std::string  sT ...

  3. FTP无法获取目录及文件

    在防火墙打开的情况下 如果不能获取,尝试将C:\windows\system32\svchost.exe 加入防火墙允许通道中. 并且设置为 主动模式

  4. Java 文件上传至leanCloud

    首先,在Controller端入参设置为 @RequestParam(value = "file",defaultValue = "") MultipartFi ...

  5. excel文档中嵌入对象(excel、word等)

    //测试环境office2016.office365 string InsertPath= @"E:\\新建文件夹\\2.xls";//插入的文档路径 string openfil ...

  6. centos7多节点部署redis4.0.11集群

    1.服务器集群服务器 redis节点node-i(192.168.0.168) 7001,7002node-ii(192.168.0.169) 7003,7004node-iii(192.168.0. ...

  7. Jenkins持续集成企业实战系列之Jenkins持续集成简介及安装-----02

    1.      Jenkins持续集成简介 注:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.    最初接触Jenkins也是由于公司需求, ...

  8. error while loading shared libraies :libopencv_core_so.3.4:cannot open shared object

    TX2 上安装自己编译的opencv,使用时出现: error while loading shared libraies :libopencv_core_so.3.4:cannot open sha ...

  9. Flask之flask_script

    flask端口占用 解决方案: lsof -i:5000 #查询是哪个进程占用的 kill PID 杀掉进程 flask_script之Manager类 from flask import Flask ...

  10. python-day15---面向对象

    面向对象零:面向对象的说明: 面向过程和面向对象: 面向对象:一切以对象为中心(解决的问题本身) 面向过程:一切以过程为中心(解决问题的步骤) 面向对象我们用 “ class 类名:” 来表示面向对象 ...