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实现:指定路径下 ...
随机推荐
- (转)15个非常棒的jQuery无限滚动插件【瀑布流效果】
原文地址:http://www.cnblogs.com/lyw0301/archive/2013/06/19/3145084.html 现在,最热门的网站分页趋势之一是jQuery的无限滚动(也即瀑布 ...
- C# 取得内网IP、外网IP、客户端IP方法
前言 在 Windows Form Application 里对于取得 IP Address 有内网.外网两种 IP Address ,如果只需要取得内网 IP Address ,可以透过使用 IPH ...
- js中的arguments 参数
function sum (a,b) { } //1,2 为实参 3,4 为形参 sum(1,2,3,4) 打印参数长度 arguments.length 函数实参长度 函数名.length
- 使用JMeter测试基于WebSocket协议的服务
使用JMeter测试基于WebSocket协议的服务 :first-child{margin-top:0!important}img.plugin{box-shadow:0 1px 3px rgba( ...
- 在iis7.5上部署asp.net mvc5
部署mvc5跟部署mvc4是一样的,唯一不同的是需要修改一下web.config的配置 在web.config中加入一下节点即可 <system.webServer> <module ...
- 数据库抽象层 pdo
一 . PDO的连接 $host = "localhost"; $dbname = "hejuntest"; $username = "root&qu ...
- Python第二周总结
之所以晚发10天是因为中途发生了很多事情,让我比较懵,甚至都想放弃学Python,但自己选择的路,在艰难也得走下去,加油!!! 补充上期str后缀小魔法: 字符串一旦创建不得修改,一旦修改或拼接,就会 ...
- 深度学习之 TensorFlow(一):基础库包的安装
1.TensorFlow 简介:TensorFlow 是谷歌公司开发的深度学习框架,也是目前深度学习的主流框架之一. 2.TensorFlow 环境的准备: 本人使用 macOS,Python 版本直 ...
- Java create azure web app
create a certificate <java-install-dir>/bin/ keytool -genkey -alias <keystore-id> -keyst ...
- Python操作hdfs
Python直接操作hdfs,包括追加数据文件到hdfs文件 #!coding:utf-8 import sys from hdfs.client import Client #设置utf-8模式 r ...