unity文件 PlayerPrefs.SetInt 保存 And PlayerPrefs.GetInt读取
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读取的更多相关文章
- Unity日常记录-本地保存未来时间实现倒计时
本地保存未来时间实现倒计时 TimeTool工具类:获取当前时间.未来时间.两时间差 using System; using UnityEngine; public class TimeTool { ...
- 【Unity系统知识】之unity文件操作路径
IOS:Application.dataPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx ...
- 以流方式读写文件:文件菜单打开一个文件,文件内容显示在RichTexBox中,执行复制、剪切、粘贴后,通过文件菜单可以保存修改后的文件。
MainWindow.xaml文件 <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&q ...
- 1、Qt Project之基本文件打开与保存
基本文件打开与保存: 首先是涉及到的头文件,我们需要在mainwindow.h包含头文件: #include <QFileDialog> #include <QFile> #i ...
- centos下修改文件后如何保存退出
centos下修改文件后如何保存退出 保存命令 按ESC键 跳到命令模式,然后: :w 保存文件但不退出vi :w file 将修改另外保存到file中,不退出vi :w! 强制保存,不推出vi :w ...
- springboot-用logback将日志文件按等级保存到不同文件
springboot-用logback将日志文件按等级保存到不同文件 案例: 例如项目基本包名为com.xxx,将该包下的所有日志按debug.info.warn.error等级分别保存到D:/log ...
- 点滴积累【C#】---C#实现上传word以流形式保存到数据库和读取数据库中的word文件。
本文修改来源:http://www.cnblogs.com/zmgdpg/archive/2005/03/31/129758.html 效果: 数据库: 思路: 首先保存word到数据库:获取上传文件 ...
- CAD保存DWG文件,设置保存的文件版本号和密码
主要用到函数说明: MxDrawXCustomFunction::Mx_SaveDwgEx 保存DWG文件,可以设置保存的文件版本号和密码,详细说明如下: 参数 说明 IN CString sFile ...
- MATLAB实例:新建文件夹,保存.mat文件并保存数据到.txt文件中
MATLAB实例:新建文件夹,保存.mat文件并保存数据到.txt文件中 作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 用MATLAB实现:指定路径下 ...
随机推荐
- 最全面的jackson json 技术
http://www.360doc.com/content/12/0429/09/7656232_207428466.shtml
- 【转】Android ActionBar完全解析,使用官方推荐的最佳导航栏(上)
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/18234477 本篇文章主要内容来自于Android Doc,我翻译之后又做了些加工 ...
- C# 控制win7任务栏、开始菜单的显示与隐藏
因为是做显示程序,故需要控制任务栏与开始菜单的显示与隐藏,这样就美观些.不啰嗦.直接上代码: using System; using System.Collections.Generic; using ...
- React + Python 七月小说网 功能设计(二)
概述 在通过对世面上的各种小说网站简单了解之后(PS:好多盗版网站真的好丑哦.),去除花里胡哨的功能,保留实用功能. 初步制定了以下几个功能需求,当然,所有需求功能都是我自己设计.自己评审,大不了到时 ...
- 解决在cmder中bash(WSL)上下箭头不能使用问题
有三种解决方式,第一种方式最简单实用 安装新版本wslbridge 这个解决方法最简单,最实用,下载第三方wslbridge,安装即可使用. 这时再进入cmder,运行bash.exe,可以发现上下左 ...
- OC字符串与C语言字符串之间的相互转换
1.C转OC字符串 const char *cString = "This is a C string"; // 动态方法 NSString *ocString1 = [[NSSt ...
- time,datetime,calendar模块
Python中,与时间有关的模块有time,datetime和calendar. 1.时钟时间:time 在Python中,用三种方式来表示时间:时间戳,格式化时间字符串和结构化时间. 1)时间戳,就 ...
- dota有哪些经典的典故或笑话?
----------------------------------------------------dota有哪些经典的典故或笑话?虽然现在玩游戏也没什么热情了, 但是看到这些还是笑尿,笑点低 = ...
- VMware虚拟机下安装CentOS系统超详细教程
链接:https://jingyan.baidu.com/article/fdffd1f8736173f3e98ca1e3.html 1.步骤一.工具准备 1.物理计算机一台 配置要求: 操作系统:w ...
- Scrapy爬虫入门Request和Response(请求和响应)
开发环境:Python 3.6.0 版本 (当前最新)Scrapy 1.3.2 版本 (当前最新) 请求和响应 Scrapy的Request和Response对象用于爬网网站. 通常,Request对 ...