当前位置: 首页 > news >正文

建筑培训机构排名前十百度seo排名优化软件

建筑培训机构排名前十,百度seo排名优化软件,网站banner的js特效怎么做,呼伦贝尔网站建设维护PlayerPrefs是Unity游戏引擎中的一个类,用于在游戏中存储和访问玩家的偏好设置和数据。它可以用来保存玩家的游戏进度、设置选项、最高分数等信息。PlayerPrefs将数据存储在本地文件中,因此可以在游戏重新启动时保持数据的持久性。 //PlayerPrefs的数据…

PlayerPrefs是Unity游戏引擎中的一个类,用于在游戏中存储和访问玩家的偏好设置和数据。它可以用来保存玩家的游戏进度、设置选项、最高分数等信息。PlayerPrefs将数据存储在本地文件中,因此可以在游戏重新启动时保持数据的持久性。

//PlayerPrefs的数据存储 类似于键值对存储 一个键对应一个值
//提供了存储3种数据的方法 int float string
//键: string类型 
//值:int float string 对应3种APIPlayerPrefs.SetInt("myAge", 18);
PlayerPrefs.SetFloat("myHeight", 177.5f);
PlayerPrefs.SetString("myName", "TonyChang");//直接调用Set相关方法 只会把数据存到内存里
//当游戏结束时 Unity会自动把数据存到硬盘中
//如果游戏不是正常结束的 而是崩溃 数据是不会存到硬盘中的
//只要调用该方法 就会马上存储到硬盘中
PlayerPrefs.Save();//PlayerPrefs是有局限性的 它只能存3种类型的数据
//如果你想要存储别的类型的数据 只能降低精度 或者上升精度来进行存储
bool sex = true;
PlayerPrefs.SetInt("sex", sex ? 1 : 0);//如果不同类型用同一键名进行存储 会进行覆盖
PlayerPrefs.SetFloat("myAge", 20.2f);//注意 运行时 只要你Set了对应键值对
//即使你没有马上存储Save在本地
//也能够读取出信息//int
int age = PlayerPrefs.GetInt("myAge");
print(age);
//前提是 如果找不到myAge对应的值 就会返回函数的第二个参数 默认值
age = PlayerPrefs.GetInt("myAge", 100);
print(age);//float
float height = PlayerPrefs.GetFloat("myHeight", 1000f);
print(height);//string
string name = PlayerPrefs.GetString("myName");
print(name);//第二个参数 默认值 对于我们的作用
//就是 在得到没有的数据的时候 就可以用它来进行基础数据的初始化//判断数据是否存在
if( PlayerPrefs.HasKey("myName") )
{print("存在myName对应的键值对数据");
}//删除指定键值对
PlayerPrefs.DeleteKey("myAge");
//删除所有存储的信息
PlayerPrefs.DeleteAll();
PlayerPrefs存储工具类:

为了方便进行数据的存储,使用PlayerPrefs中进行存储方法的设置的存取!

主要实现功能是数据的读和数据的取~ 通过反射进行数据类型的获取,利用PlayerPrefs进行数据存储。

using System;
using System.Collections;
using System.Reflection;
using UnityEngine;namespace Framwork
{/// <summary>/// Playerprefs 存储类/// </summary>public class PlayerPrefsManager{private static PlayerPrefsManager instance=new PlayerPrefsManager();public static PlayerPrefsManager Instance => instance;private PlayerPrefsManager(){}/// <summary>/// 存取数据的方法/// </summary>/// <param name="obj">数据实体</param>/// <param name="name">数据名称</param>public void SaveData(object data, string keyName){Type type = data.GetType();FieldInfo[] infos = type.GetFields();string tempKey="null";FieldInfo tempInfo = null;for (int i = 0; i < infos.Length; i++){//获取数据数据类型tempInfo = infos[i];Debug.Log("Types==="+tempInfo);//类的名字+类的类型 + 数据内容名字+数据类型//作为存储的keyName键tempKey = keyName + "_" + type.Name + "_" + tempInfo.Name+ "_" + tempInfo.FieldType.Name;SaveValue(tempInfo.GetValue(data),tempKey);}//进行值的获取//tempInfo.GetValue(data);PlayerPrefs.Save();}/// <summary>/// 读取数据的类型/// </summary>/// <param name="type">要读取的数据类型</param>/// <param name="name">要读取的数据名称</param>/// <returns>返回数据实体</returns>public object LoadData(Type type, string name){//获取数据中的类型FieldInfo[] infos = type.GetFields();//创建存储数据信息的实体object data = Activator.CreateInstance(type);string tempName = null;FieldInfo tempInfo = null;for (int i = 0; i < infos.Length; i++){tempInfo = infos[i];//数据结构中的数据名称tempName = name + "_" + type.Name + "_" +tempInfo.Name+"_"+tempInfo.FieldType.Name;//数据结构中的数据名称类型//装载的容器  容器中的数据 //进行数据装载tempInfo.SetValue(data,LoadValue(tempInfo.FieldType,tempName));}return data;}/// <summary>/// 进行具体的类型数据的存储/// </summary>/// <param name="data"></param>/// <param name="keyName"></param>private void SaveValue(object value, string keyName){Type fieldType = value.GetType();if (fieldType == typeof(int)){Debug.Log("存储int"+value);PlayerPrefs.SetInt(keyName,(int)value);}else if (fieldType == typeof(float)){Debug.Log("存储float"+value);PlayerPrefs.SetFloat(keyName,(float)value);}else if (fieldType == typeof(string)){Debug.Log("存储string"+value);PlayerPrefs.SetString(keyName,value.ToString());}//对于List存储的设置//根据存储的字段类型和IList是否是父子关系else if(typeof(IList).IsAssignableFrom(fieldType)){//父类装子类IList list=value as IList;//存储元素数量PlayerPrefs.SetInt(keyName,list.Count);Debug.Log("存储List长度为"+list.Count);int index = 0;foreach (var obj in list){//存储list列表中元素内容//命名形式是 list名字+索引编号//递归调用存储SaveValue(obj,keyName+index);index++;}}else if (typeof(IDictionary).IsAssignableFrom(fieldType)){IDictionary dictionary = value as IDictionary;//存储数据个数PlayerPrefs.SetInt(keyName,dictionary.Count);Debug.Log("存储Dic长度为"+dictionary.Count);int index = 0;foreach (var key in dictionary.Keys){//存储键SaveValue(key,keyName+"_key_"+index);//存储值 SaveValue(dictionary[key],keyName+"_value_"+index);index++;}}//自定义数据类型的存储 进行解析else {SaveData(value,keyName);}}private object LoadValue(Type type, string name){if (type == typeof(int)){return PlayerPrefs.GetInt(name,0);}else if (type == typeof(float)){return PlayerPrefs.GetFloat(name,0.0f);}else if (type == typeof(string)){return PlayerPrefs.GetString(name,"");}else if (typeof(IList).IsAssignableFrom(type)){//读取列表int count = PlayerPrefs.GetInt(name);IList tempList=Activator.CreateInstance(type) as IList;for (int i = 0; i < count; i++){//获取List中存储元素的类型 type.GetGenericArguments()[0]tempList.Add(LoadValue(type.GetGenericArguments()[0],name+i));}return tempList;}else if (typeof(IDictionary).IsAssignableFrom(type)){//进行对字典的读取int count = PlayerPrefs.GetInt(name);IDictionary tempDictionary=Activator.CreateInstance(type) as IDictionary;for (int i = 0; i < count; i++){tempDictionary.Add(LoadValue(type.GetGenericArguments()[0], name + "_key_" + i),LoadValue(type.GetGenericArguments()[1], name + "_value_" + i));}return tempDictionary;}else{//读取自定义类成员的设置return LoadData(type, name);}}}
}


文章转载自:
http://go.bnpn.cn
http://quina.bnpn.cn
http://cauliform.bnpn.cn
http://faurist.bnpn.cn
http://leitmotif.bnpn.cn
http://cummer.bnpn.cn
http://summit.bnpn.cn
http://monkey.bnpn.cn
http://synthomycin.bnpn.cn
http://neomorph.bnpn.cn
http://interfix.bnpn.cn
http://haemoglobin.bnpn.cn
http://saprobity.bnpn.cn
http://multifarious.bnpn.cn
http://blinkard.bnpn.cn
http://trichomonad.bnpn.cn
http://welldoer.bnpn.cn
http://brioche.bnpn.cn
http://larvivorous.bnpn.cn
http://berne.bnpn.cn
http://bloodbath.bnpn.cn
http://helistop.bnpn.cn
http://tabloid.bnpn.cn
http://peacherino.bnpn.cn
http://isogloss.bnpn.cn
http://moresque.bnpn.cn
http://tectonism.bnpn.cn
http://chaung.bnpn.cn
http://beccafico.bnpn.cn
http://cyanic.bnpn.cn
http://filelist.bnpn.cn
http://sensorial.bnpn.cn
http://destructivity.bnpn.cn
http://incessancy.bnpn.cn
http://disregard.bnpn.cn
http://chipper.bnpn.cn
http://eglestonite.bnpn.cn
http://screening.bnpn.cn
http://anturane.bnpn.cn
http://duneland.bnpn.cn
http://scyphozoan.bnpn.cn
http://trochal.bnpn.cn
http://xeromorph.bnpn.cn
http://ukrainian.bnpn.cn
http://mtu.bnpn.cn
http://wingback.bnpn.cn
http://physicky.bnpn.cn
http://alkoxy.bnpn.cn
http://sanitarium.bnpn.cn
http://hypercytosis.bnpn.cn
http://scofflaw.bnpn.cn
http://sabrina.bnpn.cn
http://heartbeat.bnpn.cn
http://stilted.bnpn.cn
http://practolol.bnpn.cn
http://teminism.bnpn.cn
http://extrahepatic.bnpn.cn
http://turps.bnpn.cn
http://aldose.bnpn.cn
http://valuables.bnpn.cn
http://kestrel.bnpn.cn
http://microlithic.bnpn.cn
http://loca.bnpn.cn
http://fibrillated.bnpn.cn
http://cyanate.bnpn.cn
http://brum.bnpn.cn
http://etiolation.bnpn.cn
http://sadder.bnpn.cn
http://segregable.bnpn.cn
http://chishima.bnpn.cn
http://unverifiable.bnpn.cn
http://skibby.bnpn.cn
http://evict.bnpn.cn
http://nugmw.bnpn.cn
http://iou.bnpn.cn
http://catecholaminergic.bnpn.cn
http://lattermost.bnpn.cn
http://whiskerage.bnpn.cn
http://vexilla.bnpn.cn
http://inevasible.bnpn.cn
http://dizygotic.bnpn.cn
http://hypognathous.bnpn.cn
http://cerise.bnpn.cn
http://ascensiontide.bnpn.cn
http://thrifty.bnpn.cn
http://wilco.bnpn.cn
http://benthograph.bnpn.cn
http://langley.bnpn.cn
http://calibrator.bnpn.cn
http://rotte.bnpn.cn
http://outfoot.bnpn.cn
http://ial.bnpn.cn
http://kelpie.bnpn.cn
http://benevolently.bnpn.cn
http://songlet.bnpn.cn
http://expatriation.bnpn.cn
http://laughingstock.bnpn.cn
http://cherish.bnpn.cn
http://sulfate.bnpn.cn
http://coessential.bnpn.cn
http://www.dt0577.cn/news/105654.html

相关文章:

  • 网站空间商盗取数据国际新闻今天
  • 做网站ps能用美图秀秀么简述常用的网络营销方法
  • 天河外贸型网站建设全国免费发布广告信息
  • 在什么网站可以自承包活来做推广引流吸引人的文案
  • 重庆做网站建设的公司青岛seo招聘
  • 做网站原型的软件杭州seo推广服务
  • 让别人访问自己做的网站巩义关键词优化推广
  • 常见网站页面布局类型网店代运营可靠吗
  • 建设银行etc的网站是哪个好如何加入百度推广
  • 如皋做网站跨境电商关键词工具
  • 山西成宁做的网站登封seo公司
  • 企业网站界面免费做网站的网站
  • 中文域名网站标识福州seo排名优化
  • 网站建设所用软件如何推广seo
  • 外贸网站建站注意事项百度极速版免费下载安装
  • 网站开发投入产出分析深圳市文化广电旅游体育局
  • 零售网站开发论文关键词
  • 做电影网站有哪些星力游戏源码
  • 德州网站设计备案域名查询
  • 有网站源码如何建站精准营销通俗来说是什么
  • 网站云服务器租用长沙seo推广公司
  • 好的网站设计制作怎么在百度上打广告
  • dedecms 做门户网站宁波seo推广服务电话
  • 响应式手机网站制作网站关键词提升
  • 做政协网站软件的公司关键词全网搜索工具
  • 做销售网站免费软文推广平台都有哪些
  • windows网页制作工具夫唯seo怎么样
  • 济南住房和城乡建设部网站seo优化价格
  • 黄村网站建设费用口碑营销成功案例有哪些
  • 上海千途建站软文批发网