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实现:指定路径下 ...
随机推荐
- Java IO输入输出流File 字节流
public static void main(String[] args) throws IOException { //创建源 File f =new File("file/stream ...
- (转)基于MVC4+EasyUI的Web开发框架形成之旅--界面控件的使用
原文地址:http://www.cnblogs.com/wuhuacong/p/3317223.html 在前面介绍了两篇关于我的基于MVC4+EasyUI技术的Web开发框架的随笔,本篇继续介绍其中 ...
- Daubechies Wavelet
The Daubechies wavelets, based on the work of Ingrid Daubechies, are a family of orthogonal wavelets ...
- Densely Connected Convolutional Networks(緊密相連卷積網絡)
- Dense blocks where each layer is connected to every other layer in feedforward fashion(緊密塊是指每一個層與每 ...
- spring的一些配置和重要的接口和类
spring的配置文件 通常是applicationContext.xml(具体的bean配置会在后面内容中详解) setter方法注入: <property name=“” value=“ja ...
- java 七牛上传图片到服务器(采用的html5 压缩 传输base64方式)
//html 页面如下<div class="form-group"> <label class="col-sm-2 control-label&quo ...
- 为什么 kubernetes 天然适合微服务 (3)
此文已由作者刘超授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验 四.Kubernetes 本身就是微服务架构 基于上面这十个设计要点,我们再回来看 Kubernetes,会发现 ...
- 什么时候调用dealloc
什么时候回调用dealloc? 1.这个类被release的时候会被调用: 2.这个对象的retain count为0的时候会被调用: 3.或者说一个对象或者类被置为nil的时候:
- Educational Codeforces Round 62 (Rated for Div. 2)E(染色DP,构造,思维,组合数学)
#include<bits/stdc++.h>using namespace std;const long long mod=998244353;long long f[200007][2 ...
- mysql相关的软件
数据库采用mysql,那么问题来了,mysql的部署是采用主备模式?主主模式?集群模式?在然后采取分库.分表模式? 其次:在外围的辅助开源软件的选择mycat?mybatis?keepalived?r ...